Hey there,

we would like to directly mmap large image buffers from tiff files. Our 
software checks whether:

- image is not tiled
- just a single strip, or all strips are contiguous
- strip buffer is aligned to BitsPerSample (e.g. 2byte for 16bit greyscale 
images)
- not compressed (TIFFTAG_COMPRESSION == COMPRESSION_NONE)
- follows system byte order (TIFFIsBigEndian == system byte order)
- not swapped (TIFFIsByteSwapped)
- contiguous planar config (TIFFTAG_PLANARCONFIG == PLANARCONFIG_CONTIG)

So far so good, this seems to work well for the main buffers. But now we 
received a test file with an embedded mipmap via SubIFD. Sadly, these buffers 
are all misaligned, i.e. we have these SubIFD:

    BitsPerSample (258) SHORT (3) 1<16>
    SubIFD (330) IFD (13) 4<0xa006f6 0xa80ad4 0xaa0d32 0xaa8ed0>

But `TIFFGetStrileOffsetWithErr` returns the following values for the 
respective IFDs:

    8006f5 a00ad3 a80d31 aa0ecf

As you can see, these offsets are misaligned for a 2byte/16bit greyscale 
image.

Looking at the libtiff API, we cannot find anything that would allow us to 
ensure that the SubIFDs are aligned correctly. Are we missing something or is 
this simply not possible currently?

We think that it would only require a small change in the code base, namely 
ensuring that the seek at [1] ends at an aligned address based on the 
BitsPerSample for the current IFD.

[1] https://gitlab.com/libtiff/libtiff/-/blob/master/libtiff/tif_write.c#L781

Thanks
-- 
Milian Wolff | [email protected] | Senior Software Engineer
KDAB (Deutschland) GmbH, a KDAB Group company
Tel: +49-30-521325470
KDAB - The Qt, C++ and OpenGL Experts

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Tiff mailing list
[email protected]
https://lists.osgeo.org/mailman/listinfo/tiff

Reply via email to