2011-03-08 89 views
0

可能重複:
Combining images in PHP while retaining transparency結合PNG圖像,同時保持透明度

看一看這裏:http://tyilo.jbusers.com/PNG/progress.php?l=100&p=20

我想在的末端,除去白啄藍色部分,但我已經嘗試了許多不同的事情,沒有工作。

如果能在http://tyilo.jbusers.com/PNG/文件夾(http://tyilo.jbusers.com/PNG/Empty.png

header('Content-type: image/png'); 
echo imagepng(progressbar($_GET['l'], $_GET['p'])); 
function progressbar($length, $percentage) 
{ 
$length = round($length/2) * 2; 
$percentage = min(100, max(0, $percentage)); 
if($length > 0) 
{ 
    $bar = imagecreate($length, 14); 
    $empty = imagecreatefrompng('Empty.png'); 
    $fill = imagecreatefrompng('Fill.png'); 
    $lempty = imagecreatefrompng('LeftEmpty.png'); 
    $lfill = imagecreatefrompng('LeftFill.png'); 
    $rempty = imagecreatefrompng('RightEmpty.png'); 
    $rfill = imagecreatefrompng('RightFill.png'); 
    $emptycaplength = min(7, $length/2); //5 
    imagecopy($bar, $lempty, 0, 0, 0, 0, $emptycaplength, 14); 
    imagecopy($bar, $rempty, $length - $emptycaplength, 0, 7 - $emptycaplength, 0, $emptycaplength, 14); 
    if($length > 14) 
    { 
     imagecopyresized($bar, $empty, 7, 0, 0, 0, $length - 14, 14, 1, 14); 
    } 
    $filllength = round(($length * ($percentage/100))/2) * 2; 
    $fillcaplength = min(7, $filllength/2); 
    imagecopy($bar, $lfill, 0, 0, 0, 0, $fillcaplength, 14); 
    imagecopy($bar, $rfill, $filllength - $fillcaplength, 0, 7 - $fillcaplength, 0, $fillcaplength, 14); 
    if($filllength > 14) 
    { 
     imagecopyresized($bar, $fill, 7, 0, 0, 0, $filllength - 14, 14, 1, 14); 
    } 
    return $bar; 
} 
else 
{ 
    return false; 
} 
} 

回答

0

你嘗試GD的透明度功能找到所需的PNG圖像?

imagealphablending($im,FALSE); 
imagesavealpha($im,TRUE); 
+0

是我應該把他們? – Tyilo 2011-03-08 19:02:27

+0

@Tyilo:以後每PNG ** **創造你想要合併時保持透明度。 – Shikiryu 2011-03-08 19:31:24

+0

不工作SOZ – Tyilo 2011-03-08 20:21:25