That's a very easy task for Gdiplus-X:


All samples below use the Gdiplus-x library. Get the latest stable release from codeplex:

do locfile("")

with _screen.system.drawing

   local mybitmap as xfcbitmap
   && create a bitmap object
   mybitmap =

   && save the bitmap in different formats"c:\mypng.png", .imaging.imageformat.png)
save("c:\mybmp.bmp", .imaging.imageformat.bmp)
save("c:\mytiff.tif", .imaging.imageformat.tiff)
save("c:\myjpeg.jpg", .imaging.imageformat.jpeg)
save("c:\mygif.gif", .imaging.imageformat.gif)


Of course, you can save as jpeg using the quality compression encoder parameter:
The sample below asks for an image and saves it as JPEG with quality 25. Try the values from 0 to 100.

do locfile("")

with _screen.system.drawing

   local mybitmap as xfcbitmap
   local myencoderparameter as xfcencoderparameter
   local myencoderparameters as xfcencoderparameters
   && create a bitmap object based on a bmp file.
   mybitmap ="bmp"))

   && create an encoderparameters object.
   && an encoderparameters object has an array of encoderparameter objects
   && in this case, there is only one encoderparameter object in the array.
   myencoderparameters =

   && save the bitmap as a jpeg file with quality level 25.
   && using an encoder object based on the guid
   && for the quality parameter category.
   myencoderparameter =, 25)
param.add = myencoderparameter
save("c:\myjpeg_025.jpg", .imaging.imageformat.jpeg, myencoderparameters)



4 Responses to HOW TO: Save Images in different formats with GdiPlus-X

  • THomas Baehr says:

    myEncoderParameters = .Imaging.EncoderParameters.New(1); <– the “;” was really a hard thing for me to find out why it didnt work ( esp. also coding php so ; doesnt look too bad sometimes 😉

    and yes only happend coz i removed some remarks and closed some gaps so it was

    myEncoderParameters = .Imaging.EncoderParameters.New(1);
    myEncoderParameter = .Imaging.EncoderParameter.New(myEncoder, 100)

    for me … which really freeaked me out …

    Hi Thomas,

    Thanks for reporting ! I’ve already updated the text above. Sorry for the inconvenience.



  • LuisMaria says:

    Este articulo esta traducido en

    "Como guardar imágenes en diferentes formatos con GdiPlus-X"

  • Naten Baptista says:

    During execution of the above code I seem to get the Program Error "ADD is a methode, event or Object" at the line

    myEncoderParameters.PARAM.ADD = myEncoderParameter

  • HannoStoehrmann says:

    myEncoderParameters.PARAM.ADD ( myEncoderParameter )  🙂

Leave a Reply

Your email address will not be published. Required fields are marked *