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

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

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

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

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


AA.JPG

圖片描述

每個(gè)色塊大小是 50px*50px


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

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

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

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


輸出圖片是這樣的

圖片描述

回答
編輯回答
青瓷

對(duì)的,我修改了代碼,注釋忘改了

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

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

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

rgb色系,分別是 紅red 綠green 藍(lán)blue , 所以你這個(gè)是藍(lán)色,不是紅色

2017年6月27日 09:51