图像的压缩类型

Raj*_*thy 2 c#

private static int GetCompressionType(Image image)
{
    // The zero-based index of the first occurrence within the entire array, if found; otherwise, –1.

    int compressionTagIndex = Array.IndexOf(image.PropertyIdList, 0x103);
    PropertyItem compressionTag = image.PropertyItems[compressionTagIndex];
    return BitConverter.ToInt16(compressionTag.Value, 0);
}
Run Code Online (Sandbox Code Playgroud)

程序员你好。我写了一个程序,我可以根据用户输入旋转图像(任何类型的图像)。担心的是当我旋转 tiff 图像时,它实际上是根据用户输入旋转的,但我松开了压缩,所以使用了上面的方法(用谷歌搜索)..现在我对此有一些疑问..

  1. 为什么是特定的0x103???
  2. 此方法是否特定于 Tiff ?
  3. 对于 JPG、JPEG 或 BMP,我是否需要查看压缩类型?

pli*_*nth 5

TIFF 文件格式也称为标记图像文件格式。有描述图像及其在文件中存储方式的标记和值的集合。

在这种情况下,有一个描述图像压缩的标签,恰好是标签值 0x103。现在,这只是标签。该值描述了实际的压缩类型,其中最常见的是:

  1. 无压缩
  2. CCITT霍夫曼
  3. CCITT Group 3
  4. CCITT Group 4
  5. LZW
  6. 旧式 JPEG(请勿使用
  7. 新样式 JPEG
  8. 弗拉特