Imagecolorallocate
| From: | Dan Harrington | Date: | Sat, 10 Feb 2001 00:55:42 +0000 |
| Subject: | Imagecolorallocate | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-39040@lists.php.net to get a copy of this message | ||
Hello everyone,
Alright, what's wrong with this script? I just get one big blank image.
I want the script to sequentially pull up each pixel off the template image,
and copy them pixel by pixel to the second image.
Actually, what I want to do is to process the pixels BEFORE I write them,
but this
is just a test to make sure I can write them.
I don't understand why it doesn't work. But it has something to do with my
imagecolorallocate
function, I just know it.
Mr Lynch? Anyone? :-)
Thanks
Dan
============================================================================
=====================
<?
$template = "images/alpha-shadow.jpg";
$alpha = imagecreatefromjpeg($template);
$alphasize = getimagesize($template);
$alphawidth = $alphasize[0];
$alphaheight = $alphasize[1];
$x=0;
$y=0;
$im = imagecreate (500,500);
imagecolorallocate($im,255,255,255);
while ($y <= $alphaheight){
while ($x <= $alphawidth){
$alphacolor = imagecolorat($alpha, $x, $y);
$alphaindex = imagecolorsforindex($alpha, $alphacolor);
$red = $alphaindex["red"];
$green = $alphaindex["green"];
$blue = $alphaindex["blue"];
$pixel = ImageColorAllocate($im,$red,$green,$blue);
imagesetpixel($im, $x, $y, $pixel);
imagecolordeallocate($im,$pixel);
if ($HTTP_GET_VARS["debug"] == 1){
print("($x,$y) $red $green $blue <br>");
}
++$x;
}
++$y;
$x=0;
}
if ($HTTP_GET_VARS["debug"] != 1){
Header("Content-type: image/jpeg");
imagejpeg($im);
imagedestroy($im);
}