That's a very easy task for GdiPlus-X:
IMPORTANT:
All samples below use the new GDIPlus-X library, that is still in ALPHA version, but is already stable and reliable to do the majority of GDI+ tasks. Download the latest stable release from Codeplex:
http://www.codeplex.com/Wiki/View.aspx?ProjectName=VFPX&title=GDIPlusX
DO LOCFILE("System.App")
WITH _SCREEN.System.Drawing
LOCAL myBitmap AS xfcBitmap
&& Create a Bitmap object
myBitmap = .Bitmap.New(GETPICT())
&& Save the bitmap in Different formats
myBitmap.Save("c:\MyPNG.png", .Imaging.ImageFormat.Png)
myBitmap.Save("c:\MyBMP.bmp", .Imaging.ImageFormat.Bmp)
myBitmap.Save("c:\MyTIFF.tif", .Imaging.ImageFormat.Tiff)
myBitmap.Save("c:\MyJPEG.jpg", .Imaging.ImageFormat.Jpeg)
myBitmap.Save("c:\MyGIF.gif", .Imaging.ImageFormat.Gif)
ENDWITH
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 Wuality 25. Try the values from 0 to 100.
DO LOCFILE("System.App")
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 = .Bitmap.New(GETPICT("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 = .Imaging.EncoderParameters.New(1)
&& 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 = .Imaging.EncoderParameter.New(.Imaging.Encoder.Quality, 25)
myEncoderParameters.Param.Add = myEncoderParameter
myBitmap.Save("c:\MyJPEG_025.jpg", .Imaging.ImageFormat.Jpeg, myEncoderParameters)
ENDWITH