鍍金池/ 問答/PHP/ PHP圖像處理,imagefill 疑問 (新問題)?

PHP圖像處理,imagefill 疑問 (新問題)?

bool imagefill ( resource $image , int $x , int $y , int $color )

imagefill() 在 image 圖像的坐標 x,y(圖像左上角為 0, 0)處用 color 顏色執(zhí)行區(qū)域填充(即與 x, y 點顏色相同且相鄰的點都會被填充)。

譯意我明白了,但實際操作時會出現(xiàn) BUG,不知道是瀏覽器兼容問題還是 PHP 版本問題!


AA.JPG

圖片描述

每個色塊大小是 50px*50px


<?php
$im = imagecreatefromjpeg("AA.jpg");
$blue = imagecolorallocate ( $im, 0, 0, 255 ); // 設置一個顏色變量為紅色

imagefill ( $im, 30, 80, $blue ); // 將背景設為紅色
//imagefill ( $im, 0, 0, $blue ); // 將背景設為紅色

header ( 'Content-type: image/jpg' ); // 通知瀏覽器這不是文本而是一個圖片
imagepng( $im ); // 生成PNG格式的圖片輸出給瀏覽器

imagedestroy ( $im ); //銷毀圖像資源,釋放畫布占用的內存空間
?>


輸出圖片是這樣的

圖片描述

回答
編輯回答
青瓷

對的,我修改了代碼,注釋忘改了

2018年7月12日 12:32
編輯回答
慢半拍

沒怎么用過這個函數(shù),但是

$blue = imagecolorallocate ( $im, 0, 0, 255 ); // 設置一個顏色變量為紅色

rgb色系,分別是 紅red 綠green 藍blue , 所以你這個是藍色,不是紅色

2017年6月27日 09:51