2007.09.12 11:49 "[Tiff] Modyfying TIFFTAG_COLORMAP", by mikk

Hello all,

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:

  1. Scan IFD for TIFFTAG_COLORMAP in a file opened for read/write.
  2. When found, remember its offset (position in a file).
  3. Read palette entries into buffers (being aware of byte order).
  4. Modify palette entries in buffers (apply color adjust on palette entries).
  5. Set file position to remembered offset for values of TIFFTAG_COLORMAP.
  6. Write palette entries from buffers (being aware of byte order) to file (overwrite old values of TIFFTAG_COLORMAP).
  7. 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?

Kind regards,

mikk