douwei8295 2010-06-19 14:51
浏览 122
已采纳

如何创建透明画布,然后添加透明png?

i need to create a transparent image, then combine transparent pngs to it whilst maintaining image quality.

how can i do this?

imagecreatetruecolor(...);
//processing using imagecopymerge(..);
imagepng(...);

outputs a black background.

thanks :)

here's my actual code for reference...

        $d = getimagesize(TMP.$this->files[0]);
    $source_height = $d[0];
    $source_width = $d[1];

    $this->canvas = imagecreatetruecolor($source_width*count($this->files),$source_height);

    imagealphablending($this->canvas, false );

    $i=0;
    foreach($this->files as $f){
        $dst_x = $source_width*$i;
        $im = imagecreatefrompng(TMP.$f);
        imagecopyresampled  (  $this->canvas  , $im  ,
               $dst_x  ,
               $dst_y = 0 , 
               $src_x = 0 ,
               $src_y = 0 ,
               $source_width  ,
               $source_height  ,
               $source_width  ,
               $source_height);

        $i++;
        imagepng($im,TMP.$i.".png");
        if($i>3)break;
    }
    $fn = TMP."stiched_up_$i*$source_width.png";
    imagesavealpha($this->canvas,TRUE);
    imagepng($this->canvas,$fn);
  • 写回答

2条回答 默认 最新

  • doouzlrvb01417498 2010-06-19 14:57
    关注
     $img = imagecreatetruecolor(...);
     imagealphablending($img,false);
     //rest of code.
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?