开发者

php gd imagesetpixel, pixels not a 1 to 1 relationship with pixels and interior model of image

开发者 https://www.devze.com 2023-01-06 00:58 出处:网络
<? $img_w = 800; $img_h = 600; $img = imagecreate($img_w, $img_h); $color = imagecolorallocate($img, 230, 230, 230);
<?
    $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开发者_JS百科.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消