我正在尝试通过JPEG压缩将图像从JPEG(彩色)转换为灰度8位TIFF,但是我的输出是24位黑白TIFF。
我不确定该如何解决:
Bitmap img = new Bitmap(oImage.FilePath);
// Set Encoder Parameters
EncoderParameters eps = new EncoderParameters(2);
eps.Param(0) = new EncoderParameter(Encoder.ColorDepth, 8L);
eps.Param(1) = new EncoderParameter(Encoder.Compression, long.Parse(((EncoderValue)(selEncoderValue.SelectedItem))));
// Set image CodecInfo
ImageCodecInfo[] ie = ImageCodecInfo.GetImageEncoders();
ImageCodecInfo tiffEncoder = null;
for (int i = 0; (i <= (ie.Length - 1)); i++) {
if ((ie(i).MimeType == "image/tiff")) {
tiffEncoder = ie(i);
break;
}
}
string sImageConvertedFilePath = FileExistIncrementer(string.Format("{0}\\{1}_{2}.tif", Path.GetDirectoryName(oImage.FilePath), Path.GetFileNameWithoutExtension(oImage.FileName), selEncoderValue.SelectedItem.ToString));
img.Save(sImageConvertedFilePath, tiffEncoder, eps);
这些是格式正确的图像的属性: