php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #30863 imagecolortransparent and imagetruecolortopalette don't mix
Submitted: 2004-11-22 16:53 UTC Modified: 2004-11-23 15:30 UTC
From: hp at oeri dot ch Assigned: pajoye (profile)
Status: Not a bug Package: GD related
PHP Version: 5.0.2 OS: Windows XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: hp at oeri dot ch
New email:
PHP Version: OS:

 

 [2004-11-22 16:53 UTC] hp at oeri dot ch
Description:
------------
If I create a truecolor image and
a) set a color as transparent
b) use imagetruecolortopalette
the result is offset by one in "x" direction and a black vertical line at x=0.

Leaving out either a or b gives the correct result (no offset).

Didn't find this bug anywhere, am however unable to compile on Windows.

Reproduce code:
---------------
<?php
		header( "Content-Type: image/png" );

		$im = imagecreatetruecolor( 750, 400 );

		$bg = imagecolorallocate( $im, 0xFF, 0xAA, 0xAA );
		imagecolortransparent( $im, $bg );											// EITHER THIS
		imagefilledrectangle( $im, 0, 0, 749, 399, $bg );

		$c2 = imagecolorallocate( $im, 0x01, 0x23, 0x45 );
		imagerectangle( $im, 0, 0, 749, 399, $c2 );

		imagetruecolortopalette( $im, false, 256 );							// OR THAT
		imagepng( $im );
?>

Expected result:
----------------
palette image, 750x400 with a rectangle along the borders

Actual result:
--------------
palette image, 750x400, with a rectangle open to the right (offset 1)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-11-23 15:30 UTC] pajoye@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

Use dithering to get out of that. The color approximation (even with 2colors..) is "better".

--Pierre
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 20:01:31 2024 UTC