douduocuima61392 2016-03-29 08:01
浏览 79

图像旋转导致背景变化

i wrote code with flips image and then rotate it at -60 degree, issue is that rotated parts background is more darker than original image.

used sample image is transparent png image

summary of what i did 1: i make white layer A 2: put image on layer A using imagecopyresampled 3: flipped layer A , rotated Layer A

image used :http://img10.deviantart.net/07aa/i/2013/058/2/7/png_branch_by_moonglowlilly-d5wdjdp.png

output image output image

$image1=imagecreatefrompng($_GET["v1"]);
$image2=imagecreatefrompng($_GET["v1"]);
//filter_opacity( $image1, 25 );

$w=imagesx($image1);
$h=imagesy($image1);
$finala = imagecreatetruecolor($w, $h);
$finalb = imagecreatetruecolor($w, $h);
$finalc = imagecreatetruecolor($w, $h);

$backgroundColora = imagecolorallocate($finala, 255,255,255); // white bg
$backgroundColorb = imagecolorallocate($finalb, 255,255,255); // white bg
$backgroundColorc = imagecolorallocate($finalc, 255,255,255); // white bg

imagefill($finala, 0, 0, $backgroundColora);
imagefill($finalb, 0, 0, $backgroundColorb);
imagefill($finalc, 0, 0, $backgroundColorc);


$percent = 0.583;
$new_width = $w * $percent;
$new_height = $h * $percent;
$wshift = $w/8.5;
$hshift = $h/2.5;


imagecopyresampled($finala, $image2,$wshift,$hshift,0,0, $new_width, $new_height, $w, $h);
imagecopyresampled($finalc, $image2,$wshift,$hshift,0,0, $new_width, $new_height, $w, $h);
imagecopyresampled($finalb, $finalc,$w*0.3,$h*0.3,0,0, $w*0.6, $h*0.6, $w, $h);
imageflip($finala, IMG_FLIP_HORIZONTAL );


$finala = imagerotate($finala, -60, imageColorAllocateAlpha($finala, 255, 255, 255, 127));
imagecopyresampled($finalb, $finala,-$w*0.1,-$h*0.1,0,$h*0.20, $new_width, $new_height, $w, $h);
header('Content-Type: image/jpeg');
imagejpeg($finalb);
imagedestroy($finala);
imagedestroy($image2);
imagedestroy($image1);
imagedestroy($final);
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 2020长安杯与连接网探
    • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
    • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
    • ¥16 mybatis的代理对象无法通过@Autowired装填
    • ¥15 可见光定位matlab仿真
    • ¥15 arduino 四自由度机械臂
    • ¥15 wordpress 产品图片 GIF 没法显示
    • ¥15 求三国群英传pl国战时间的修改方法
    • ¥15 matlab代码代写,需写出详细代码,代价私
    • ¥15 ROS系统搭建请教(跨境电商用途)