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
m.lcSource = GETPICT()
m.lcDestination = JUSTPATH(m.lcSource) + "\_" + JUSTSTEM(m.lcSource)

LOCAL loImage AS gpimage OF HOME() + ffc / _gdiplus.vcx
m.loImage = NEWOBJECT("gpimage", HOME() + "ffc/_gdiplus.vcx")
m.loImage.CreateFromFile(m.lcSource)
m.loImage.SaveToFile(m.lcDestination + ".jpg","image/jpeg")
m.loImage.SaveToFile(m.lcDestination + ".bmp","image/bmp")
m.loImage.SaveToFile(m.lcDestination + ".tif","image/tiff")
m.loImage.SaveToFile(m.lcDestination + ".gif","image/gif")
m.loImage.SaveToFile(m.lcDestination + ".png","image/png")

*!* jpegs allow to choose the quality of the image
m.loImage.SaveToFile(m.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