LOCAL lcSource, lcInfo, lnWidth, lnHeight, lnHorRes, lnVerRes, lnPixForm LOCAL lcpixform m.lcSource = GETPICT() LOCAL loImage AS gpImage OF FFC / _GdiPlus.vcx m.loImage = NEWOBJECT("gpimage", HOME() + "ffc/_gdiplus.vcx") m.loImage.CreateFromFile(m.lcSource) m.lnWidth = m.loImage.ImageWidth m.lnHeight = m.loImage.ImageHeight m.lnHorRes = m.loImage.HorizontalResolution m.lnVerRes = m.loImage.VerticalResolution m.lnPixForm = m.loImage.PixelFormat m.lcpixform = GetPixFormatName(m.lnPixForm) m.lcInfo = "image : " + m.lcSource + CHR(13) + CHR(13) + ; "width : " + TRANSFORM(m.lnWidth) + " pixels" + CHR(13) + ; "height : " + TRANSFORM(m.lnHeight) + " pixels" + CHR(13) + ; "pixel format : " + m.lcpixform + CHR(13) + ; "hor. resol : " + TRANSFORM(m.lnHorRes) + " pixels/inch" + CHR(13) + ; "ver. resol : " + TRANSFORM(m.lnVerRes) + " pixels/inch" + CHR(13) MESSAGEBOX(m.lcInfo, 64, "image information") RETURN PROCEDURE GetPixFormatName(npix) DO CASE CASE m.npix = 0x00030101 RETURN "1bppindexed" CASE m.npix = 0x00030402 RETURN "4bppindexed" CASE m.npix = 0x00030803 RETURN "8bppindexed" CASE m.npix = 0x00101004 RETURN "16bppgrayscale" CASE m.npix = 0x00021005 RETURN "16bpprgb555" CASE m.npix = 0x00021006 RETURN "16bpprgb565" CASE m.npix = 0x00061007 RETURN "16bppargb1555" CASE m.npix = 0x00021808 RETURN "24bpprgb" CASE m.npix = 0x00022009 RETURN "32bpprgb" CASE m.npix = 0x0026200a RETURN "32bppargb" CASE m.npix = 0x000e200b RETURN "32bpppargb" CASE m.npix = 0x0010300c RETURN "48bpprgb" CASE m.npix = 0x001c400e RETURN "64bpppargb" OTHERWISE RETURN "unidentified" ENDCASE ENDPROC
VFP Visual FoxPro and Images, graphics, GdiPlus, GdiPlusX, FoxCharts, FoxPaint, charting, tips and tricks, code samples, VFPX, FoxyPreviewer etc...
2006-03-01
GETTING IMAGE PROPERTIES WITH GDI+
Subscribe to:
Post Comments (Atom)
Cesar
ReplyDeleteExcellent as ever - small typo in code
"Height : " + TRANSFORM(lnWidth)
should be
"Height : " + TRANSFORM(lnHeight)
Hi Chris,
Thanks for reporting ! I've already updated the text.
Regards,
Cesar
Thanks for this code. It is very usefull. Ca you get more information from an image file this way (camera to take the picture, lens aperture, etc.)?
ReplyDeleteThank you!
Of course it is possible !
We have a great sample in the GdiPlusX samples. Please download the samples project from GdiPlusX, and run the sample "ImageProps.Scx", or directly from the samples menu select "Image Properties". It uses the function "GetPropertyItem" to retrieve the metadata embedded in the picture file. Try the sample, selecting some digital pictures that you took with your camera, and you'll find some really cool info.
Hope this helps !