2006-02-07

CONVERT IMAGE TYPES WITH VFP9 AND GDI+

The following piece of code loads an image and saves it on the same original folder in the formats supported by GDI+, using the _gdiPlus.vcx class, that you can find in the VFP9 FFC folder:

local lcSource, lcDestination
lcSource = getpict()
lcDestination = justpath(lcSource) + "\_" + juststem(lcSource)


local loImage as gpimage of home() + ffc/_gdiplus.vcx
loImage = newobject("gpimage", home() + "ffc/_gdiplus.vcx")
loImage.CreateFromFile(lcsource)
loImage.SaveToFile(lcDestination + ".jpg","image/jpeg")
loImage.SaveToFile(lcDestination + ".bmp","image/bmp")
loImage.SaveToFile(lcDestination + ".tif","image/tiff")
loImage.SaveToFile(lcDestination + ".gif","image/gif")
loImage.SaveToFile(lcDestination + ".png","image/png")

*!* jpegs allow to choose the quality of the image
loImage.SaveToFile(lcDestination + ".jpg","image/jpeg", "quality=70")

1 comment:

  1. Versión en Español de este artículo in / Spanish version at http://www.portalfox.com/article.php?sid=2174

    ReplyDelete