constructor of this object.then you have to
create ImageCodecInfo and select mime type for
output format.to set the quality and compression
of the output image,you must make Encode
parameters object representing the list for
Encoderparamter objects.for encoding,image
encoder uses a set of parameters represented
by the object.
the code is shown below -
static void Main(string[] args)
{
Bitmap bitmapImage=new Bitmap(@"bitmap.bmp");
ImageCodecInfo testImageCoInfo =
GetEncoderInfo("image/gif"); ;
EncoderParameter encCompressParameter =
new EncoderParameter(System.Drawing.Imaging.
Encoder.Compression, (long)
EncoderValue.CompressionLZW); ;
EncoderParameter encQuaParam = new
EncoderParameter(System.Drawing.Imaging.Encoder.
Quality, 0L);EncoderParameters testEncoderParam
= new EncoderParameters(2);testEncoderParam.Param[0]
=encCompressParameter;
testEncoderParam.Param[1] = encQuaParam;
myBitmap.Save("output_image.gif", testImageCoInfo,
testEncoderParam);
}
the funtion used is -
private static ImageCodecInfo GetEncoderInfo(String mimeTypedef)
{
int conter;
ImageCodecInfo[] encoderObj;
encoderObj = ImageCodecInfo.GetImageEncoders();
for (counter = 0; counter < encoders.Length; ++counter)
{
if (encoders[counter].MimeType == mimeTypedef)
return encoderObj[counter];
}
return null;
}