tags:

views:

27

answers:

1
<?
    $img_w = 800;
    $img_h = 600;
    $img = imagecreate($img_w, $img_h);
    $color = imagecolorallocate($img, 230, 230, 230);
    $imgname = "gd_img.png";


    for($n=0; $n < $img_w; $n++)
    {
        plot($n , $img_h/2, imagecolorallocate($img, 200, 0, 0));
        plot($n+4 , $img_h/2 + 10, imagecolorallocate($img, 0, 200, 0));
        plot($n*2 , $img_h/2 + 20, imagecolorallocate($img, 0, 0, 200));
    }
    imagepng($img, $imgname, $color);
    imagedestroy($img);


    function plot($x, $y, $color=0)
    {

        imagesetpixel($GLOBALS['img'], $x, $y, $color);
    }

?>

Try it, youll see that there should be a solid line 800 pixels wide. There is not, at least on my end. The FireFox WebDeveloper addon (the ruler tool under misc->display ruler) shows the top line at about 83 pixels wide.

A: 

Depending on your HTML code to insert the image, your browser could resize the image to fit the page elements.

JochenJung