• Welcome to Vampyre Imaging Library Forum. Please login or sign up.
 

Bug in ImagingTiff code with attached TIFF image file

Started by Max Nilson, 28 May 2008, 09:29:24

Previous topic - Next topic

Max Nilson

28 May 2008, 09:29:24 Last Edit: 28 May 2008, 09:34:30 by Max Nilson
Just has our in house support throw this file my way. Turns out that there is 7 directories in the TIFF file and one of them (the 4th) is grey scale with an alpha channel, and the code in TTiffFileFormat.LoadData, line 327 that reads

    if Info.ChannelCount > 1 then
      SwapChannels(Images[Idx], ChannelRed, ChannelBlue);

tries to swap non existent red and blues channels. Interestingly enough the comment above the definitions for ChannerlBlue/Red/Green/Alpha mentions that these can only be used for ARGB images, but in this case there is no checking that the TIFF directory has an ARGB image format, it makes the assumption based on number of channels.

I also note that the saving code forther down in the source makes the same assumption that more than 1 channel implies that there are RGB channels available. So any fixes needs to be handled in both places in the code.

I'm going to hack my source to work for now, but I'm not familiar with the code base to make a correct determination on which ImageFormat types that the channels should be swapped.

Cheers, Max.

Galfar

Thanks for reporting this bug!

Correct if condition in loading function should be
if (Photometric = PHOTOMETRIC_RGB) or (DataFormat = ifUnknown) then
  SwapChannels(Images[Idx], ChannelRed, ChannelBlue);

to swap only RGB images and images got from TiffLib RGBA interface (ifUnknown format).
Saving is the same but without the DataFormat check.
I'll update SVN repository with this fix in few hours.

Quick Reply

With Quick-Reply you can write a post when viewing a topic without loading a new page. You can still use bulletin board code and smileys as you would in a normal post.

Name:
Email:

Shortcuts: ALT+S save/post or ALT+P preview

SMF spam blocked by CleanTalk