image functions?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Jugular
Forum Newbie
Posts: 1
Joined: Thu Mar 06, 2003 12:19 am

image functions?

Post by Jugular »

I'm trying to draw two rectangles in an image to achieve a square with a one pixel rounded edges. What I get is one rectangle with no roundness. Any ideas? Here's the main section of code I'm trying:

$pic=imageCreate($boxWidth,$boxHeight);
imageFilledRectangle($pic, $boxLeft+1, $boxTop, $boxRight-1, $boxBottom, imageColorAllocate($pic,$boxGray,$boxGray,$boxGray));
imageFilledRectangle($pic, $boxLeft, $boxTop+1, $boxRight, $boxBottom-1, imageColorAllocate($pic,$boxGray,$boxGray,$boxGray));
Header("Content-type: image/png");
imagePNG($pic);
imageDestroy($pic);
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

try

Code: Select all

$pic = imagecreate($boxWidth,$boxHeight);
$colorBG = imageColorAllocate($pic, 255, 255, 255);
$colorFG = imageColorAllocate($pic, $boxGray, $boxGray, $boxGray);
imageFilledRectangle($pic, $boxLeft+1, $boxTop, $boxRight-1, $boxBottom, $colorFG);
imageFilledRectangle($pic, $boxLeft, $boxTop+1, $boxRight, $boxBottom-1, $colorFG); 

Header("Content-type: image/png");
imagePNG($pic);
imageDestroy($pic);
the first colour allocated is the background colour
Post Reply