Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
VFP 6 JPG and GIF support
Message
De
30/08/1998 19:16:08
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00121341
Message ID:
00131393
Vues:
22
Hi John...

Now that I have VFP6 I'm trying to put to use code that you were so generous in giving me. Just to refresh, this code determines the size and width of a JPG or GIF and it was needed so that I could customize the way a jpg fits onto a form next to a list box. If the JPG was wider than normal, then the list box would shrink in width, etc., etc.

When I try running this code, I get different values compared to the size that shows up in Adobe Photoshop for the same image. For a particular JPG, your code gives me 211 w x 355 h. Photoshop gives me 120 w x 216 h. I assume these are both in pixels.

Am I doing something wrong?

Thanks in advance.

Rixon

>>Is there a command in VFP6 to capture the height and width of a jpg or gif?

See code below...

>Also, does jpg/gif support mean that jpgs and gifs can be added to forms?

Yes, JPG's and GIFS can be used where BMP's can be used. However, animated gifs - while you can view them - the image is static.


Try this code:

o = createobject("cuspicture")
o.loadpicture
?o.picturewidth
?o.pictureheight


Define Class cusPicture as Custom
Picturefile= Null
PictureWidth = 0
PictureHeight = 0

PROCEDURE loadpicture
lParameters cFile
Local oFile,oConvert
oConvert = CreateObject("cusScaleConvert")
*/ This will reset the Picture Object Reference

If Type("Cfile") # "C" Or !File(cFile)
cFile = GetPict()
Endif
If !Empty(cFile) And File(cFile)
oFile = LoadPicture(cFile)
If Type("oFile") = "O" And ;
!IsNull(oFile)
With This
.PictureFile = oFile
.PictureWidth = oFile.Width/oConvert.nFactorX
.PictureHeight = oFile.Height/oConvert.nFactorY
EndWith
Endif
Endif
Return
ENDPROC
EndDefine

DEFINE CLASS cusscaleconvert AS custom


nfactorx = 0
nfactory = 0
Name = "cusscaleconvert"


PROCEDURE convert
LOCAL lihwnd,lihdc,lipixelsperinchx,lipixelsperinchy
* Define some constants.
#DEFINE cnlog_pixels_x 88
#DEFINE cnlog_pixels_y 90
#DEFINE cntwips_per_inch 1440

DECLARE integer GetActiveWindow in WIN32API
DECLARE integer GetDC in WIN32API integer iHDC
DECLARE integer GetDeviceCaps ;
in WIN32API integer iHDC, integer iIndex

lihwnd = getactivewindow()
lihdc = getdc(lihwnd)

lipixelsperinchx = getdevicecaps(lihdc, cnlog_pixels_x)
lipixelsperinchy = getdevicecaps(lihdc, cnlog_pixels_y)

WITH This
.nfactorx = cntwips_per_inch/lipixelsperinchx
.nfactory = cntwips_per_inch/lipixelsperinchy
ENDWITH

Return
ENDPROC


PROCEDURE Init
This.Convert()
ENDPROC


ENDDEFINE<<
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform