Re: [GD-DEVEL] Newbie transparent gif question- possibly solved.
[email protected] (Roger Oberholtzer) Tue, 06 May 2008 23:25:58 +0200
| Newsgroups | php.gd.devel |
|---|---|
| Message-ID | <[email protected]> |
On Tue, 2008-05-06 at 17:40 +0200, Pierre Joye wrote: > On Tue, May 6, 2008 at 5:29 PM, Roger Oberholtzer <[email protected]> wrote: > > > So you agree. Granted, the coding here is perhaps not what should be > > done. But it does demonstrate a red image with red set to be the > > transparent color - that will not have a transparent background. This > > code is obviously incorrect in execution, if not in intention. > > Either I'm getting bad at explaining things or you focus way too much > on the RGB values instead of the main ideas behind palette images: > Indexed colors :) Perhaps the problem is my description. I too am focused on indexes. If indexes were not used, my original problem would not have occurred. > > > > Read in a file that already contains red and has that as the background > > > > color, and do this: > > > > > > > > # read file > > > > red = gdImageColorAllocate(im, 255,0,0); > > > > gdImageColorTransparent(im, red); > > > > # save file > > > > > > > > The background will no longer be transparent. Even it it was when you > > > > read the file. > > > > > > Please provide a file showing this case. > > > > I will re-break my program and provide you with one. This is more what I > > was doing at the beginning of all my problems. I would make a new image > > and define a transparent color as the first color, and save it to a > > file. I would then read in the file and once again define (Allocate) the > > same RGB values as a color and make it the transparent color - just as I > > had done when I first made the image. At which time, my transparency > > vanished. > > Again (sigh), RGB values in palette images are completely irrelevant, > GD uses the indexes. But yes, a sample code will help me to help you In GD, if I Allocate the same color multiple times using the same RGB values, I would obtain more than one index for the same color. And I could use any of those indexes interchangeably to draw the color to which the indexes refer. Visibly these colors will look the same, even though they are using different indexes into the color map. But only one index can be defined to be transparent. If you are unlucky and Allocate and use the colors and define the transparent color in a specific sequence - there will be no transparency. BECAUSE of the use of indexes. -- Roger Oberholtzer OPQ Systems / Ramböll RST Ramböll Sverige AB Kapellgränd 7 P.O. Box 4205 SE-102 65 Stockholm, Sweden Tel: Int +46 8-615 60 20 Fax: Int +46 8-31 42 23