using this code i am trying to compress 69Kb file into 12 Kb in C#. But i am unable to do this in Windows mobile. In Windows mobile ImageCodecInfo and EncoderParameters are not supporting.
CODE
string ImagePath = @"\\My Documents\\sampleimage.jpg";
string newImagePath = @"\\My Documents\\CompressedImage.jpg";
Bitmap ImgTemp;
ImgTemp = new Bitmap(ImagePath);
SaveJPGWithCompressionSetting(ImgTemp, newImagePath, 10L);
// Get the desired Codec
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for (j = 0; j < encoders.Length; ++j)
{
if (encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}
// Get the desired Encoder and Quality
private void SaveJPGWithCompressionSetting(Image image, string szFileName, long lCompression)
{
EncoderParameters eps = new EncoderParameters(1);
eps.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, lCompression);
ImageCodecInfo ici = GetEncoderInfo("image/jpeg");
image.Save(szFileName, ici, eps);
}