Re: [GD-DEVEL] Problems copying PNG with Alpha-Transparency
[email protected] (Dieter Guthmann) Wed, 15 Jul 2009 12:01:47 +0200
| Newsgroups | php.gd.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello, problem solved... I had to use "gdImageCreateTrueColor" to get a nice result... sorry. But why is the Background of my Image allways black when I replace gdImageCreate with gdImageCreateTrueColor? Best Rgds. Dieter Dieter Guthmann schrieb: > hope 14k for the PNG-File are ok. > Below the C-Code I've used for generating the attached file. As > "PNG_transparency_demonstration_1.png" I used the Demonstration-Image > which you can get here: > > <http://de.wikipedia.org/w/index.php?title=Datei:PNG_transparency_demonstration_1.png&filetimestamp=20090422121649> > > > ========== > gdImagePtr dest, sourceGd; > FILE *pngout, *sourcefile; > int white; > > sourcefile = fopen( "PNG_transparency_demonstration_1.png", "rb" ); > sourceGd = gdImageCreateFromPng( sourcefile ); > fclose( sourcefile ); > > dest = gdImageCreate( 840, 640 ); > > white = gdImageColorAllocate( dest, 255, 255, 255 ); > > gdImageCopy( dest, > sourceGd, > 20, > 20, > 0, > 0, > gdImageSX( sourceGd ), > gdImageSY( sourceGd ) ); > > pngout = fopen( "result.png", "wb" ); > > gdImagePngEx( dest, pngout, 9 ); > > fclose( pngout ); > > gdImageDestroy( dest ); > gdImageDestroy( sourceGd );