Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Properties of a Bitmap or JPEG
Message
 
À
17/01/2000 13:02:41
Loren Fedje
Loren D. Fedje & Associates Ltd.
Chilliwack, Colombie Britannique, Canada
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00318732
Message ID:
00319179
Vues:
23
>Walter - I thought something was funny when the returned value for a bitmap with a width of 550 pixels returned a value of 14,600. All I did was determine the factor of 26.458 and with some simple division ended up with the results I required.
>

The height and width from an object created with LoadPicture() are in HIMETRIC: Each logical unit is 0.01 millimeter (2540 HIMETRIC units per inch). So, the factor conversion to pixels isn't fixed, it is base on the current display device capabilities.
For a generic method, you must get the display properties and then perform the conversion.

Here is a function (and a sample usage) for this.
#define HIMETRIC_PER_INCH   2540
#define LOGPIXELSX    88
#define LOGPIXELSY    90

* Sample usage of HimetricToPixel procedure
Local oPictObj, cPicName, nPixelX, nPixelY

cPicName = 'testpic.jpg'
oPictObj = LoadPicture(cpicname)

nPixelX = oPictObj.Width
nPixelY = oPictObj.Height

? 'Before conversion :', nPixelX, nPixelY
HimetricToPixel(@nPixelX, @nPixelY)
? 'After Conversion :', nPixelX, nPixelY

Return

* Convert from Himetric to Pixel
* Parameters must be passed by reference:
*   WidthHimetric, HeighHimetric
Procedure HimetricToPixel
  LParameters nHimetricX, nHimetricY

  Declare Integer MulDiv in win32api ;
          Integer nNumber, integer nnumerator, integer ndenominator
  Declare Integer GetDC in win32api Integer hWnd
  Declare Integer GetDeviceCaps in win32api Integer HDC, Integer nIndex
  Declare ReleaseDC in win32api Integer hWnd, Integer hDC

  Local nhDCScr, nxppli, nyppli

  nhDCScr = GetDC(0)
  nxppli = GetDeviceCaps(nhDCScr, LOGPIXELSX)
  nyppli = GetDeviceCaps(nhDCScr, LOGPIXELSY)
  ReleaseDC(0, nhDCScr)

  nHimetricX = MulDiv(nxppli, nHimetricX, HIMETRIC_PER_INCH)
  nHimetricY = MulDiv(nyppli, nHimetricY, HIMETRIC_PER_INCH)

EndProc

Just an opinion... Not a fact.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform