ID:               50183
 Updated by:       paj...@php.net
 Reported By:      scratch65535 at att dot net
-Status:           Open
+Status:           Feedback
 Bug Type:         GD related
 Operating System: W2K
 PHP Version:      5.2.11
 New Comment:

Please provide a link to the image you get and what you would expect.


Previous Comments:
------------------------------------------------------------------------

[2009-11-15 16:38:18] scratch65535 at att dot net

Description:
------------
I am trying to combine PNG images by 'pasting' them onto a transparent
background such that I end up with one large image (the 'assembly')
rather than a multitude of small ones.  I'm using PNG because I need
more than 8 bits/pixel.  I created the images in p'shop 7.

Using a GIF works fine, apart from it having too few bits per pixel.

Using a PNG with a designated xparent color ("GIF mode", as it were)
also works fine.

PNG with alpha doesn't.  I don't know whether the problem is in the
documentation, in imageCreateFromPNG(), in my understanding, or
somewhere else.  I've fooled around with different combinations (e.g.,
putting in or taking out imageAlphaBlending() for the $dest value) but
nothing seems to help.

(Using PNGs in 'GIF mode' will be my fallback if alpha is broken, but
it would mean re-doing all my images so I'm hoping alpha is NOT broken)

Reproduce code:
---------------
$png = 1 ;

if ( $png == 1 )  // png in 'gif mode'
{
    $dest       = imageCreateTrueColor( 200, 200 ) ;
    $xparent    = imageColorAllocate( $dest, 220,2,240 ) ;
    imageFilledRectangle($dest, 0,0, 200,200, $xparent) ;
    imageColorTransparent($dest, $xparent);

    $src        = imageCreateFromPNG( 'TESTcolor.png' ) ;
    $srcxparent = imageColorAllocate( $src, 0xFF,0,0xFF ) ;
    imageColorTransparent($src, $srcxparent ) ;
    imageCopyMerge( $dest, $src, 50, 50, 0, 0, 100, 100,  100 ) ;

    header('Content-Type: image/png') ;
    imagePNG( $dest ) ;
}
else // png with alpha
{
    $dest       = imageCreateTrueColor( 200, 200 ) ;
    $xparent    = imageColorAllocateAlpha( $dest, 0xFF,0x99,0xFF, 0 );
    imageFilledRectangle($dest, 0,0, 200,200, $xparent) ;
    imageAlphaBlending( $dest, 1 ) ;    
    imageSaveAlpha( $dest, 1 ) ;
   
    $src        = imageCreateFromPNG( 'TESTalpha.png' ) ;
    imageAlphaBlending( $src, 1 ) ;
    imageSaveAlpha( $src, 1 ) ;
    imageCopyMerge( $dest, $src, 50, 50, 0, 0, 100, 100,  100 ) ;

    header('Content-Type: image/png') ;
    imagePNG( $dest ) ;
}


Expected result:
----------------
I expect to see a dark blue outline box on the background color of the
page itself.

Actual result:
--------------
I see a dark blue outline box on an opaque white field overlaying the
assembly field that I painted magenta.  I can get rid of the magenta by
calling imageColorTransparent() on $dest, but nothing I can do gets rid
of the white background of the box.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=50183&edit=1

Reply via email to