gpt4 book ai didi

tiff - 如何找出 FreeImage 中 TIFF 图像的压缩情况?

转载 作者:行者123 更新时间:2023-12-02 11:46:54 32 4
gpt4 key购买 nike

我使用 FreeImage 处理多页 TIFF 文件,有时我在 FIBITMAP 中有一个 TIFF 页面,我需要知道它的压缩情况。知道如何做到这一点吗?

最佳答案

FreeImage 没有内置函数来显示 tiff 文件压缩方案,但是您可以使用 Exif 元数据来弄清楚(dib 是本地 FIBITMAP 变量,这是 C# 代码):

    public string GetCompressionName()
{
long _compression;

if (dib.IsNull)
throw new Exception("dib is empty - image haven't been loaded!");

//Searching tag in metadata.
ImageMetadata iMetadata = new ImageMetadata(dib);

foreach (MetadataModel metadataModel in iMetadata)
{
if (metadataModel.ToString() == "FIMD_EXIF_MAIN")
{
try
{ long.TryParse(metadataModel.GetTag("Compression").ToString(), out _compression); }
catch
{ return "Unknown"; }


if (CompressType.ContainsKey(_compression))
{
string _compressionName;
CompressType.TryGetValue(_compression, out _compressionName);

if (_compressionName != null)
{
return _compressionName;
}
}
}
}

return "Unknown";
}

Dictionary<long, string> CompressType = new Dictionary<long, string>()
{
{1, "Uncompressed" } ,
{2, "CCITT modified Huffman RLE"},
{32773, "PackBits"},
{3, "CCITT3"},
{4, "CCITT4"},
{5, "LZW"},
{6, "JPEG_old"},
{7, "JPEG_new"},
{32946, "DeflatePKZIP"},
{8, "DeflateAdobe"},
{9, "JBIG_85"},
{10, "JBIG_43"},
{11, "JPEG"},
{12, "JPEG"},
{32766, "RLE_NeXT"},
{32809, "RLE_ThunderScan"},
{32895, "RasterPadding"},
{32896, "RLE_LW"},
{32897, "RLE_HC"},
{32947, "RLE_BL"},
{34661, "JBIG"},
{34713, "Nikon_NEF"},
{34712,"JPEG2000"}
};

关于tiff - 如何找出 FreeImage 中 TIFF 图像的压缩情况?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5431385/

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