$img = imagecreatetruecolor(200,200);用这个函数为什么总是创建的是黑色的图片呢而用imagecreate这个却可以呢,但手册里为什么又要推荐使用imagecreatetruecolor() 来创建呢?

解决方案 »

  1.   

    本函数需要 GD 2.0.1 或更高版本(推荐 2.0.28 及更高版本)。
    本函数不能用于 GIF 文件格式。 手册上有推荐用这个函数创建彩图么?
    建议楼主更新你的PHP手册。
      

  2.   

    imagecreatetruecolor 创建真彩图片
    imagecreate 创建位图图片两者均创建初始背景为空(黑色)的图片,只不过位图图片会将第一个定义的颜色作为背景为什么又要推荐使用 imagecreatetruecolor() 来创建呢?
    除gif格式只允许256色调色板外,其他图片格式都是真彩的。这就是原因
      

  3.   

    好像还是没有说到点子上,imagecreatetruecolor() 能创建彩色图片,那么如何设置背景色呢?
    我的版本太低了吗?
      

  4.   

    $im = imagecreatetruecolor(100,100);//创建真彩图片
    $background = imagecolorallocate($im, 255, 0, 0);//设置一个颜色
    imagefill($im, 0, 0, $background);//充填图片
    imagegif($im);如果是位图
    $im = imagecreate(100,100);
    $background = imagecolorallocate($im, 255, 0, 0);
    imagegif($im);
      

  5.   

    说明
    resource imagecreatetruecolor ( int x_size, int y_size )
    imagecreatetruecolor() 返回一个图像标识符,代表了一幅大小为 x_size 和 y_size 的黑色图像。 
     
     創建的是黑色的圖像
    創建彩色圖像可以這樣$im = imagecreate(100, 100);
    $bg   = imagecolorallocate($im, 230, 230, 230);
    imagefilledrectangle($im,0,0,100,100,$bg);
      

  6.   

    5楼的方法可以,thank you!!!!
      

  7.   

    画一个方块然后填充
    PHP code
    $im = imagecreate(100, 100);
    $bg   = imagecolorallocate($im, 230, 230, 230);
    imagefilledrectangle($im,0,0,100,100,$