Foxite.COM Community Weblog

Foxite.COM Community Weblog - free weblog service for the Visual FoxPro Community.
Welcome to Foxite.COM Community Weblog Sign in | Join | Help
in
Home Blogs Forum Photos Forum Archives

VFP IMAGING



_Gdiplus.vcx and SavetoFile

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".

Man, I've lost a lot of time to find that !

*()&)(*)%@&$(@&¨!)@*(_*(&!_()&*_)(&*+_*()

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
Published Thursday, April 06, 2006 2:26 PM by cesarchalom
Filed Under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

No Comments

What do you think?

(required) 
(optional)
(required)