Vampyre Imaging Library Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Imaging 0.26.4 Released!

Author Topic: Bug in ImagingTiff code with attached TIFF image file  (Read 1191 times)

Max Nilson

  • Imaging User
  • *
  • Offline Offline
  • Posts: 1
    • View Profile
    • Email

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.
« Last Edit: 28 May 2008, 09:34:30 by Max Nilson »
Logged

Galfar

  • Administrator
  • Imaging User
  • *****
  • Offline Offline
  • Posts: 249
    • ICQ Messenger - 327174200
    • View Profile
    • Galfar's Homepage
    • Email
Re: Bug in ImagingTiff code with attached TIFF image file
« Reply #1 on: 28 May 2008, 23:08:05 »

Thanks for reporting this bug!

Correct if condition in loading function should be
Code: [Select]
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.
Logged
 

Page created in 0.079 seconds with 20 queries.