|
Post by boggan on Dec 16, 2012 14:38:17 GMT 1
Does anyone know if there's an EASY way in Gb32 to get the dimensions of a image file regarless of type? Is there anything built-in, if it is i cant find it. Since Gfa supports most gfx types and loads them automatically, finding the dimensions shouldnt be that hard? I dont want to open a window to find out either.
|
|
|
Post by boggan on Dec 16, 2012 17:54:35 GMT 1
I solved the problem myself, heres how.
Local z$ = Space$(25) 'Make room for 25 Bytes of the Header+DIB. Open ":star" for Input As # 1 'Open file for input. BGet # 1, V:z$, 25 'Get 25 bytes Close # 1 'Close file.
Local size = LPeek(V:z$ + 2) 'Get byte 3 & 4 from header (Image Size on Disk, bytes 1-2 only contains BM for identification) Local width = LPeek(V:z$ + 18)'Get byte 19-22 (Width) Local height = LPeek(V:z$ + 22)'Get byte 23+ (Height)
Print width Print height
'Enjoy! /Boggan
|
|
|
Post by dragonjim on Jan 7, 2013 15:55:19 GMT 1
GFA supports .bmp, .jpg and .gif files through the Windows Picture object.
If you load the desired picture using the LoadPicture command, properties .Height and .Width hold the picture dimensions. HOWEVER, these dimensions are in himet; to convert to pixels use:
pic.Width * Screen.TwipsPerHimet * Screen.PixelsPerTwipX pic.Height * Screen.TwipsPerHimet * Screen.PixelsPerTwipY
This should mean you don't have to physically load the file into the program first. I hope this helps.
|
|