The method SaveToFile from GpImage class in _gdiplus.vcx from VFP9 “Saves the image object to a disk file, using specified encoder or image format and optional parameters.”
Here are the most important:
QUALITY (Supported by JPEG)
Specifies the compression level when you save a JPEG image. A quality level of 0 corresponds to the greatest compression, and a quality level of 100 corresponds to the least compression.
Example 1: Saves image with quality of 70%
LOCAL lcSource
lcSource = GETPICT()
LOCAL loImage AS GpImage OF HOME() + ffc/_gdiplus.vcx
loImage = NEWOBJECT("GpImage", HOME() + "ffc/_gdiplus.vcx")
loImage.CreateFromFile(lcSource)
loImage.SaveToFile("c:\MyImage.jpg","image/jpeg", "quality=70")
TRANSFORMATION (Supported by JPEG)
GDI+ provides the following transformations that can be performed on JPEG images without loss of information:
Rotate 90 degrees
Rotate 180 degrees
Rotate 270 degrees
Flip horizontally
Flip vertically
Each of those listed above corresponds to a Gdiplus Constant, that needs to be passed together with the “transformation” encoder.
The transformation will proceed without loss of information if the file used to construct the Image object is a JPEG file and the width and height of the image are both multiples of 16. If the width and height of the image are not both multiples of 16, GDI+ will do its best to preserve the image quality when you apply one of the rotation or flipping transformations.
Example 2: Saves image with quality of 50% AND Rotate 180 degrees
#DEFINE EncoderValueTransformRotate90 13
#DEFINE EncoderValueTransformRotate180 14
#DEFINE EncoderValueTransformRotate270 15
#DEFINE EncoderValueTransformFlipHorizontal 16
#DEFINE EncoderValueTransformFlipVertical 17
LOCAL lcSource
lcSource = GETPICT()
LOCAL loImage AS GpImage OF HOME() + ffc/_gdiplus.vcx
loImage = NEWOBJECT("GpImage", HOME() + "ffc/_gdiplus.vcx")
loImage.CreateFromFile(lcSource)
loImage.SaveToFile("c:\MyImage.jpg","image/jpeg", ;
"quality=50, transformation=14")
This makes rotating and flipping a very simple and quick operation!
For TIFF Images, these are the commonest parameters:
SAVEFLAG (Supported by TIFF)
See my article at UTMAG from May 2006: “Multiframe Images with GDI+”
http://www.utmag.com/wconnect/wc.dll?9,7,10,,2115
Used for the creation and manipulation of multiframed images.
COMPRESSION (Supported by TIFF)
#DEFINE EncoderValueCompressionLZW 2
#DEFINE EncoderValueCompressionCCITT3 3
#DEFINE EncoderValueCompressionCCITT4 4
#DEFINE EncoderValueCompressionRle 5
#DEFINE EncoderValueCompressionNone 6
COLORDEPTH (Supported by TIFF)
Color Depth in Bytes per pixel.
These are defined by GDI+ but not supported by any of the standard encoders: 'COMPRESSION', 'SCANMETHOD', 'VERSION' and 'RENDERMETHOD'.
Source: MSDN
See also this blog post: ROTATE / FLIP IMAGES WITH VFP9 AND GDI+