我正在使用 CCIT4 压缩创建 tif 图像。此图像没有 EOFB。有人可以帮我如何将此 EOFB 添加到 tif 图像中。或者如何使用 EOFB 信息创建图像。
这是我在没有 EOFB 的情况下生成图像的代码
var tifImg = new Bitmap(500, 500);
tifImg.SetResolution(200, 200);
Graphics graphic = Graphics.FromImage(tifImg);
graphic.FillRectangle(new SolidBrush(Color.White), new Rectangle(0, 0, 500, 500));
try
{
string data = "My data";
Font vrFont = new Font("Verdana", 32, GraphicsUnit.Pixel);
Size micrSize = TextRenderer.MeasureText(data, vrFont);
graphic.DrawString(data, vrFont, new SolidBrush(Color.Black), new Point(10, 100));
Rectangle rectangle = new Rectangle(10, 20, 200, 60);
graphic.DrawRectangle(new Pen(new SolidBrush(Color.Black)), rectangle);
SaveImage(tifImg, fileName, appLogger);
var imageEncoders = System.Drawing.Imaging.ImageCodecInfo.GetImageEncoders().ToList();
var imageCodecInfo = imageEncoders.FirstOrDefault(o => o.MimeType == "image/tiff");
var encoderParameter = new System.Drawing.Imaging.EncoderParameters(2);
encoderParameter.Param[0] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.Compression, (long)System.Drawing.Imaging.EncoderValue.CompressionCCITT4);
encoderParameter.Param[1] = new System.Drawing.Imaging.EncoderParameter(System.Drawing.Imaging.Encoder.SaveFlag, (long)18);
tifImg.Save(fileName, imageCodecInfo, encoderParameter);
}
catch { throw; }
finally
{
graphic.Dispose();
tifImg.Dispose();
}
谢谢,
埃森