gpt4 book ai didi

c# - 如何在 tif 图像中添加 EOFB(传真 block 结束)

转载 作者:太空宇宙 更新时间:2023-11-03 11:18:54 28 4
gpt4 key购买 nike

我正在创建一个采用 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();
}

谢谢,

亦森

最佳答案

这是我在项目中所做的代码。检查这是否对您有帮助。

 private void AddEOFB(string imgFileName)
{
var fs = new FileStream(imgFileName, FileMode.Append, FileAccess.Write);
try
{
fs.Seek(0, SeekOrigin.End);
var buf = BitConverter.GetBytes(0x00100100);
fs.Write(buf, 0, buf.Length);
}
catch { throw; }
finally
{
fs.Close();
fs.Dispose();
}
}

关于c# - 如何在 tif 图像中添加 EOFB(传真 block 结束),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11696856/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com