Re: [GD-DEVEL] Problems copying PNG with Alpha-Transparency
| From: | Dieter Guthmann | Date: | Wed, 15 Jul 2009 10:01:47 +0000 |
| Subject: | Re: [GD-DEVEL] Problems copying PNG with Alpha-Transparency | ||
| References: | 1 2 3 | Groups: | php.gd.devel |
| Request: | Send a blank email to php-gd-devel+get-589@lists.php.net to get a copy of this message | ||
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 );