Bug #53757 [Bgs]: can't change the background
| From: | kalle@php.net | Date: | Sun, 16 Jan 2011 00:52:07 +0000 |
| Subject: | Bug #53757 [Bgs]: can't change the background | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5816@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53757&edit=1
ID: 53757
Updated by: kalle@php.net
Reported by: mesmsgs at gmail dot com
Summary: can't change the background
Status: Bogus
Type: Bug
Package: Documentation problem
Operating System: Windows 7
PHP Version: 5.2.17
Assigned To: ross
Block user comment: N
Private report: N
New Comment:
To be more verbose why this is not working;
it works with imagecreate() based instances because it returns a palette
based image, whereas with imagecreatetruecolor() that is not the case.
The first color allocated in a palette based image will always change
the background color (unless overwritten). Where in true color based
images (that defaults to a black background) you must create a rectangle
to overlay the image to change the background.
Previous Comments:
------------------------------------------------------------------------
[2011-01-15 17:03:47] ross@php.net
After some confusion (thinking you included the original example in your
report)
it turns out the example is not wrong. In future, please don't submit
help
requests as bug reports, try the php.general mailing list, an IRC
channel or a
support site such as StackOverflow.
As for your query, try adding this line underneath where you set $bg:
imagefill($image, 0, 0, $bg);
Regards
------------------------------------------------------------------------
[2011-01-15 16:33:13] ross@php.net
Hi,
You are correct, the example is wrong as imagecolorallocate only sets
the
background colour on palette-based images (imagecreatetruecolor should
be
imagecreate). I'll fix the example.
------------------------------------------------------------------------
[2011-01-15 16:05:44] mesmsgs at gmail dot com
Description:
------------
---
From manual page:
http://www.php.net/function.imagefilledellipse#Exemples
---
I can't change the background color
Test script:
---------------
<?php
// create a blank image
$image = imagecreatetruecolor(400, 300);
// fill the background color
$bg = imagecolorallocate($image, 255, 255, 255);
// choose a color for the ellipse
$col_ellipse = imagecolorallocate($image, 0, 0, 0);
// draw the white ellipse
imagefilledellipse($image, 200, 150, 300, 200, $col_ellipse);
// output the picture
header("Content-type: image/png");
imagepng($image);
?>
Expected result:
----------------
The background color must be white
Actual result:
--------------
Only black background
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=53757&edit=1