Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine the size of a bmp-file
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Photos et traitement d'images
Divers
Thread ID:
00386335
Message ID:
00386394
Vues:
16
>I know that it is possible to use API-calls to determine the picture size of a bitmap (lenght and width) but I'm not sure how to do it.
>
>With the API-Viewer I know what the VB-calls are....how are they matched to VFP?
>Public Declare Function GetBitmapDimensionEx Lib "gdi32" Alias "GetBitmapDimensionEx" (ByVal hBitmap As Long, lpDimension As SIZE) As Long
>
>Can any give one give me some help on determining this?
>
>Thanks in advance,
>
Ron,

You can use the API, but it really involves more work than you need to do. The following snippet (and function) retrieves the width and height from the BITINFOHEADER structure of the file directly.
* lcfile is the bitmap file of interest
lcbitmap = FILETOSTR(lcfile)
lcwidth = SUBSTR(lcbitmap, 19, 4)
lcheight = SUBSTR(lcbitmap, 23, 4)
lnwidth = StringToInteger(lcwidth)
lnheight = StringToInteger(lcheight)

FUNCTION StringToInteger
    
  LPARAMETER pcstring, plsigned
  
  LOCAL lnresult, lnlast, lni, llsigned,;
    lnmsb, lnmax
  lnresult = 0
  lnlast = LEN(pcstring)
  * Return Signed Integer?
  IF PCOUNT() = 2
    llsigned = plsigned
  ELSE
    llsigned = .F.
  ENDIF
  FOR lni = 1 TO lnlast
    lnresult = lnresult + ASC(SUBSTR(pcstring, lni, 1)) * (256 ^ (lni - 1))
  NEXT
  IF llsigned
    lnmsb = (lnlast * 8) - 1
    IF BITTEST(lnresult, lnmsb)
      lnmax = (2 ^ (lnmsb + 1))
      lnresult = lnresult - lnmax
    ENDIF
  ENDIF
  RETURN lnresult
ENDFUNC
hth,
George

Ubi caritas et amor, deus ibi est
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform