doufu7464 2011-11-09 12:53
浏览 36

我有一个反映GD PHP代码,我想用原始的组成

The following code will create a reflection of an image, but only the reflection. I want it to add this reflection under the original image.

Here's my code:

<?php
$im = 'path/to/image.jpg'; // The input image
$size = getimagesize($im);
$rH = 50; // Reflection height
$tr = 30; // Starting transparency
$div = 1; // Size of the divider line
$w = $size[0];
$h = $size[1];

$im = imagecreatefromjpeg($im);
$li = imagecreatetruecolor($w, 1);
$bgc = imagecolorallocate($li, 255, 255, 255); // Background color
imagefilledrectangle($li, 0, 0, $w, 1, $bgc);
$bg = imagecreatetruecolor($w, $rH);
$wh = imagecolorallocate($im,255,255,255);

$im = imagerotate($im, -180, $wh);
imagecopyresampled($bg, $im, 0, 0, 0, 0, $w, $h, $w, $h);
$im = $bg;
$bg = imagecreatetruecolor($w, $rH);
for ($x = 0; $x < $w; $x++) {
    imagecopy($bg, $im, $x, 0, $w-$x, 0, 1, $rH);
}
$im = $bg;

$in = 100/$rH;
for($i=0; $i<=$rH; $i++){
    if($tr>100) $tr = 100;
    imagecopymerge($im, $li, 0, $i, 0, 0, $w, 1, $tr);
    $tr+=$in;
}
imagecopymerge($im, $li, 0, 0, 0, 0, $w, $div, 100); // Divider
header('content-type: image/jpeg');
imagejpeg($im, '', 100);
imagedestroy($im);
imagedestroy($li);
?>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 BP神经网络控制倒立摆
    • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
    • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
    • ¥30 Unity接入微信SDK 无法开启摄像头
    • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
    • ¥20 cad图纸,chx-3六轴码垛机器人
    • ¥15 移动摄像头专网需要解vlan
    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算