Do you see something wrong in the code below ?
local lcSource, lcDest
lcSource = getpict()
lcDest = 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(lcdest + ".png","image/png")
That's a very simple code, that is supposed to load an image and save it as a png. But nothing happens ! Can you guess why ???
The Savetofile method from gpimage class from _gdiplus.vcx must receive as a required second parameter, the "tvclsidencoder", that can be the clsid of the encoder to use, or a MIME type, eg "image/jpeg
" or "image/png
". If a MIME type is specified, then the method dynamically looks up the clsid of the appropriate encoder.
99% of us pass the mime type, because that's easier to remember, but be careful ! Because that parameter mime type, is CASE SENSITIVE!
You have always to pass this parameter in lowercase !
The code above did not work because i typed "image/png" instead of "image/png".
By the way, the MIME (multipurpose internet mail extensions) types of the encoders built into microsoft windows GDI+ are as follows:
- image/bmp
- image/jpeg
- image/gif
- image/tiff
- image/png
No comments:
Post a Comment