我有一個tiff文件,它在原始創建和保存期間具有壓縮類型「LZW」。C#Tiff文件壓縮#
System.Drawing.Bitmap bitmap = new System.Drawing.Bitmap(800, 1000);
Graphics g = Graphics.FromImage(bitmap);
fileName = saveDirectory + id + ".tif";
bitmap.Save(fileName, ImageFormat.Tiff);
所以我想它的壓縮變爲CCIT: -
Bitmap myBitmap;
myBitmap = new Bitmap(fileName);
ImageCodecInfo myImageCodecInfo;
myImageCodecInfo = GetEncoderInfo("image/tiff");
System.Drawing.Imaging.Encoder myEncoder;
myEncoder = System.Drawing.Imaging.Encoder.Compression;
EncoderParameters myEncoderParameters;
myEncoderParameters = new EncoderParameters(1);
EncoderParameter myEncoderParameter;
myEncoderParameter = new EncoderParameter(myEncoder,(long)EncoderValue.CompressionCCITT4);
myEncoderParameters.Param[0] = myEncoderParameter;
myBitmap.Save(new_fileName);
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;
}
然而,通過運行的過程後,我的文件屬性仍然說,這是「LZW壓縮」型的。
任何人都可以向我解釋我在哪裏出錯嗎?
退房的回答這個問題[轉換TIFF LZW到CCITT(http://stackoverflow.com/questions/16319508/convert-tiff-lzw-to -ccitt) – Logarr
不是我原來的問題的解釋。但是,感謝您的鏈接。 – Philo