Author Topic: GIF Transparency  (Read 1806 times)

Offline pourkwapa

  • Imaging User
  • *
  • Posts: 2
    • View Profile
GIF Transparency
« 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?

Code: [Select]
  img := TSingleImage.Create;
  img.Format := ifA8R8G8B8;
  img.LoadFromFile(FileName);

pourkwapa, loving this library :)

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 312
    • View Profile
    • Galfar's Homepage
Re: GIF Transparency
« Reply #1 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.

Offline pourkwapa

  • Imaging User
  • *
  • Posts: 2
    • View Profile
Re: GIF Transparency
« Reply #2 on: 3 December 2007, 11:27:59 »
Thanks for the tips. I will check with the svn code.

Yurik

  • Guest
Re: GIF Transparency
« Reply #3 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

Offline Galfar

  • Administrator
  • Imaging User
  • *****
  • Posts: 312
    • View Profile
    • Galfar's Homepage
Re: GIF Transparency
« Reply #4 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.