如果你用 int imagecreatefromgif(string filename); 來取出一張 GIF 格式圖形,當(dāng)背景或者基本的畫布樣本使用,在其上繪制圖形,請注意: 如果這個文件中沒有的色素,你將不能使用。
解決方法,你可以用 int imagecreate(int x_size, int y_size); 建立一張全空的圖形。在其上繪制圖形。將黑色作為透明色。 這個新建的圖形要和原圖形大小相同,絕對位置相同,將其放在原圖形上方,就可以了。
<img border="0" src=http://www.okasp.com/techinfo/"1.gif" style="position: absolute; left: 1; top: 1; z-index: 0" width="200" height="300"> 原圖形文件
<img border="0" src="photo.php" style="position: absolute; left: 1; top: 1; z-index: 1" width="200" height="300"> 全空文件 photo.php
photo.php 的代碼: <?php Header("Content-type: image/gif"); $im = imagecreate(200,300); $black = ImageColorAllocate($im, 0,0,0); $red = ImageColorAllocate($im, 255,0,0); $blue = ImageColorAllocate($im, 0,0,255);
imagerectangle($im,100,200,150,200,$red) ; imagestring($im,2,120,150,"aaaaaaaa",$blue);
imagecolortransparent($im,$black); //將黑色作為透明色
ImageGif($im); ImageDestroy($im);
?>
【本文版權(quán)歸作者與奧索網(wǎng)共同擁有,如需轉(zhuǎn)載,請注明作者及出處】
|