Vampyre Imaging Library Forum

Imaging Category => Bugs And Other Insects => Topic started by: pourkwapa on 2 December 2007, 17:15:44

Title: GIF Transparency
Post by: pourkwapa on 2 December 2007, 17:15:44
Hello,

I try to load a GIF image, and convert it later to a TGA.
The transparency is always lost. The same code works well for PNG files.

Am I doing something wrong, or is there a problem with GIF Transparency?


  img := TSingleImage.Create;
  img.Format := ifA8R8G8B8;
  img.LoadFromFile(FileName);


pourkwapa, loving this library :)
Title: Re: GIF Transparency
Post by: Galfar on 3 December 2007, 00:29:18
Yes, there was a problem with GIF background color transparency settings.
It is fixed now, new code is in SVN repository.

Also you don't need to set image format before loading (like in your code example).
Whole image (size, format, etc.) is thrown away during loading.
Title: Re: GIF Transparency
Post by: pourkwapa on 3 December 2007, 11:27:59
Thanks for the tips. I will check with the svn code.
Title: Re: GIF Transparency
Post by: Yurik on 12 April 2008, 05:53:06
Hello! Thanks for this great library!

I have a question -- what for is this line in ImagingGIF.pas:

Quote
    if HasGlobalPal then
    begin
      for I := 0 to GlobalPalLength - 1 do
      begin
        GlobalPal.A := 255;
        Read(Handle, @GlobalPal.R, SizeOf(GlobalPal.R));
        Read(Handle, @GlobalPal.G, SizeOf(GlobalPal.G));
        Read(Handle, @GlobalPal.B, SizeOf(GlobalPal.B));
      end;
      GlobalPal[Header.BackgroundColorIndex].A := 0;
    end;


i.e. line 843: GlobalPal[Header.BackgroundColorIndex].A := 0;

This makes non-transparent GIF images to be shown transparently. It is not correct.

Best regards,

Yury Plashenkov
www.IndaSoftware.com
Title: Re: GIF Transparency
Post by: Galfar on 14 April 2008, 01:20:45
Looks like a fix for some transparent images that screwed up nontransparent ones.

I changed the code so now it behaves the same as most viewers/editors (for nontransparent GIFs, transparent GIFs with disposal methods defined and those without them).

Updated code is in SVN repository.