2007.09.12 11:49 "[Tiff] Modyfying TIFFTAG_COLORMAP", by mikk
I need to modify colors in TIFF image with PHOTOMETRIC = PALETTE. I want to do it as fast as possible. My idea is to do it without decoding the image data when reading and without involving any codec functions for writing.
My idea is:
- Scan IFD for TIFFTAG_COLORMAP in a file opened for read/write.
- When found, remember its offset (position in a file).
- Read palette entries into buffers (being aware of byte order).
- Modify palette entries in buffers (apply color adjust on palette entries).
- Set file position to remembered offset for values of TIFFTAG_COLORMAP.
- Write palette entries from buffers (being aware of byte order) to file (overwrite old values of TIFFTAG_COLORMAP).
- Are my assumptions for this algorithm OK? Am I right when I assume that these modifications in the TIFF file structure is safe in all cases?