Re: [GD-DEVEL] Problems copying PNG with Alpha-Transparency

[email protected] (Dieter Guthmann) Wed, 15 Jul 2009 10:33:45 +0200
Newsgroups php.gd.devel
Message-ID <[email protected]>
Hello Pierre,

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>


Rgds.
Dieter


==========
  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 );



Pierre Joye schrieb:
> Please show the result images too and the application or script you
> use to generate them (small if possible)
>
> On Tue, Jul 14, 2009 at 5:11 PM, Dieter Guthmann<[email protected]> wrote:
>   
>> Hello,
>>
>> I've tested today copying a PNG-File with Alpha-Transparency to an image
>> (new, empty) with libgd. The result doesn't look beautiful... some parts
>> of the half-transparent areas are missing, and the background in the
>> target-Image looks like chessboard.
>> I've used gdImageCopy and gdImageCopyResampled but the results are the
>> same. Is copying of PNGs with Alpha-Transparency currently not
>> implemented or do I have to use another function for that purpose?
>>
>> The image I've tested with is here:
>> <http://de.wikipedia.org/w/index.php?title=Datei:PNG_transparency_demonstration_1.png&filetimestamp=20090422121649>
>>