PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Fri Sep 18, 2020 4:41 am

All times are UTC - 5 hours




Post new topic Reply to topic  [ 12 posts ] 
Author Message
PostPosted: Mon Aug 15, 2005 9:28 am 
Offline
DevNet Resident

Joined: Tue May 18, 2004 5:32 am
Posts: 1445
Location: London, UK
Syntax: [ Download ] [ Hide ]
$color = imagecolorallocate($im, 0, 0, 0);



imageline($im, 5, 19, 66, 867, $color);

imageline($im, 54, 65, 543, 543, $color);  

imageline($im, 55, 3, 1, 166, $color);  

imageline($im, 98, 12, 543, 1, $color);


That should draw 4 black lines, right?

Well, it seems to make the lines any color it likes (although they are alll the same color) - white, red, in fact pretty much anything except for black :(

Have I got this function totally wrong, or what?


Last edited by Grim... on Tue Aug 16, 2005 8:28 am, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 9:46 am 
Offline
Forum Contributor

Joined: Sat Feb 19, 2005 9:35 am
Posts: 332
Location: USA


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 9:51 am 
Offline
DevNet Resident

Joined: Tue May 18, 2004 5:32 am
Posts: 1445
Location: London, UK
No, Black is 255,255,255 (or #FFFFFF).

And the numbers before the color are the line co-ordinates.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 11:00 am 
Offline
Jedi Mod
User avatar

Joined: Tue Dec 21, 2004 6:03 pm
Posts: 5263
Location: usrlab.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 11:01 am 
Offline
Jedi Mod
User avatar

Joined: Tue Dec 21, 2004 6:03 pm
Posts: 5263
Location: usrlab.com


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 11:12 am 
Offline
Forum Contributor

Joined: Sat Feb 19, 2005 9:35 am
Posts: 332
Location: USA


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 11:25 am 
Offline
DevNet Resident

Joined: Tue May 18, 2004 5:32 am
Posts: 1445
Location: London, UK


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 11:26 am 
Offline
DevNet Resident

Joined: Tue May 18, 2004 5:32 am
Posts: 1445
Location: London, UK


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 2:02 pm 
Offline
Jedi Mod
User avatar

Joined: Tue Dec 21, 2004 6:03 pm
Posts: 5263
Location: usrlab.com
0,0,0,0 is black if you've got an alpha channel.. but anyway..

I tried this code, and it works fine on my dev machine here. Only I have GD2 rather than GD, so maybe that's an issue..

My code:
Syntax: [ Download ] [ Hide ]
<?php



        $im = imagecreate(1000,600);

        $color = imagecolorallocate($im, 255, 255, 255);

        imagefill($im,0,0,$color);



        $color = imagecolorallocate($im, 0, 0, 0);



        imageline($im, 5, 19, 66, 867, $color);

        imageline($im, 54, 65, 543, 543, $color);  

        imageline($im, 55, 3, 1, 166, $color);  

        imageline($im, 98, 12, 543, 1, $color);



        header("Content-type: image/jpeg");

        imagejpeg($im);



?>


The only thing I can suggest is posting the entire code.. maybe there's a variable change going on somewhere that you've missed.

EDIT: Actually.. are you opening an image and drawing onto it?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Aug 15, 2005 4:31 pm 
Offline
DevNet Resident

Joined: Tue May 18, 2004 5:32 am
Posts: 1445
Location: London, UK
Here it is:

Syntax: [ Download ] [ Hide ]
function drawrectangle($image, $tlx, $tly, $brx, $bry)

{  

    //set variable names

    $original_image = $image;

    $filename = "images/user/note/".$image;

    $image = "images/user/cutdown/".$image;

   

    //load original image

    $im = imagecreatefromjpeg($image);

    $color = imagecolorallocate($im, 0, 0, 0);

   

    //draw rectangle

    imageline($im, $tlx, $tly, $brx, $tly, $color);

    imageline($im, $tlx, $bry, $brx, $bry, $color);  

    imageline($im, $tlx, $tly, $tlx, $bry, $color);  

    imageline($im, $brx, $tly, $brx, $bry, $color);

   

    //get image size

    $w = imagesx($im);

    $h = imagesy($im);

   

    //create new image

    $dest = imageCreate($w, $h);

    imagecopy($dest, $im, 0, 0, 0, 0, $w, $h);

    imagejpeg($dest, $filename, 100);

   

    //delete temp images

    imagedestroy($dest);

    imagedestroy($im);

}


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 4:54 am 
Offline
Jedi Mod
User avatar

Joined: Tue Dec 21, 2004 6:03 pm
Posts: 5263
Location: usrlab.com


Top
 Profile  
 
 Post subject:
PostPosted: Tue Aug 16, 2005 8:27 am 
Offline
DevNet Resident

Joined: Tue May 18, 2004 5:32 am
Posts: 1445
Location: London, UK
I'm doing 5 shortly, but 3 will be fine for now.

Cheers :)


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group