php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #29834 imagecolorAllocate doesnt set backgroundcolor after imageCreateTrueColor
Submitted: 2004-08-25 14:59 UTC Modified: 2004-08-26 02:07 UTC
From: waszm at freemail dot hu Assigned:
Status: Not a bug Package: GD related
PHP Version: 5.0.1 OS: win32
Private report: No CVE-ID: None
 [2004-08-25 14:59 UTC] waszm at freemail dot hu
Description:
------------
When I use imageCreateTrueColor instead of imageCreate, and I call imagecolorAllocate(), the background color won't be changed.
I got a black background instead of a green. My gd version is bundled (2.0.28 compatible)

Reproduce code:
---------------
<?php
$image1=imageCreate(100, 100);
$image2=imageCreateTrueColor(100, 100);
$green1=imageColorAllocate($image1, 0, 128, 256);
$green2=imageColorAllocate($image2, 0, 128, 256);

print'In case of imagCreate(): ';
if(imageColorAt($image1, 1, 1)==$green1){
	print'Ok, background is green.';
}else{
	print'Background is black.';
}

print'<br>In case of imagCreateTrueColor(): ';
if(imageColorAt($image2, 1, 1)==$green2){
	print'Ok, background is green.';
}else{
	print'Background is black.';
}
?>

Expected result:
----------------
In case of imagCreate(): Ok, background is green.
In case of imagCreateTrueColor(): Ok, background is green.

Actual result:
--------------
In case of imagCreate(): Ok, background is green.
In case of imagCreateTrueColor(): Background is black.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-08-26 02:07 UTC] iliaa@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

imagecolorAllocate() is for images created via 
imagecreate() (256 colors only). 
 
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Dec 03 21:00:01 2025 UTC