浏览代码

LibGfx/TIFF: Add support for the IFD type

As described in the first edition of the TIFF technical notes, the IFD
type is identical to Long (UnsignedLong) except that it only contains
offset of valid IFDs.

https://www.awaresystems.be/imaging/tiff/specification/TIFFPM6.pdf
Lucas CHOLLET 1 年之前
父节点
当前提交
1d0a762cdb

+ 1 - 0
Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.cpp

@@ -468,6 +468,7 @@ private:
         }
         }
         case Type::UnsignedShort:
         case Type::UnsignedShort:
             return read_every_values.template operator()<u16>();
             return read_every_values.template operator()<u16>();
+        case Type::IFD:
         case Type::UnsignedLong:
         case Type::UnsignedLong:
             return read_every_values.template operator()<u32>();
             return read_every_values.template operator()<u32>();
         case Type::UnsignedRational:
         case Type::UnsignedRational:

+ 4 - 0
Userland/Libraries/LibGfx/ImageFormats/TIFFLoader.h

@@ -11,8 +11,12 @@
 
 
 namespace Gfx {
 namespace Gfx {
 
 
+// This is a link to the main TIFF specification from 1992
 // https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf
 // https://www.itu.int/itudoc/itu-t/com16/tiff-fx/docs/tiff6.pdf
 
 
+// First TIFF Technical notes from 1995
+// https://www.awaresystems.be/imaging/tiff/specification/TIFFPM6.pdf
+
 namespace TIFF {
 namespace TIFF {
 class TIFFLoadingContext;
 class TIFFLoadingContext;
 }
 }

+ 2 - 1
Userland/Libraries/LibGfx/TIFFGenerator.py

@@ -40,6 +40,7 @@ class TIFFType(EnumWithExportName):
     SignedRational = 10, 8
     SignedRational = 10, 8
     Float = 11, 4
     Float = 11, 4
     Double = 12, 8
     Double = 12, 8
+    IFD = 13, 4
     UTF8 = 129, 1
     UTF8 = 129, 1
 
 
 
 
@@ -218,7 +219,7 @@ def tiff_type_to_cpp(t: TIFFType, with_promotion: bool = True) -> str:
         return 'ByteBuffer'
         return 'ByteBuffer'
     if t == TIFFType.UnsignedShort:
     if t == TIFFType.UnsignedShort:
         return 'u16'
         return 'u16'
-    if t == TIFFType.UnsignedLong:
+    if t == TIFFType.UnsignedLong or t == TIFFType.IFD:
         return 'u32'
         return 'u32'
     if t == TIFFType.UnsignedRational:
     if t == TIFFType.UnsignedRational:
         return 'TIFF::Rational<u32>'
         return 'TIFF::Rational<u32>'