提供各式廣告招牌有專業設計規劃及製作團隊
銀行業者共同供應契約廠商,歡迎洽詢
搜尋引擎拆鐵皮屋、拆廠房、大型廢棄物清運
一通電話,馬上為您服務!

首頁  •  j2h 論壇 • 程式設計討論     • 

[教學] 高畫質縮圖函式

房東:紅妹
發表時間:2010-06-01


function ImageResize (&$src, $x, $y) {
$dst=imagecreatetruecolor($x, $y);
$pals=ImageColorsTotal ($src);
for ($i=0; $i<$pals; $i++) {
$colors=ImageColorsForIndex ($src, $i);
ImageColorAllocate ($dst, $colors['red'], $colors['green'], $colors['blue']);

}
$scX =(imagesx ($src)-1)/$x;
$scY =(imagesy ($src)-1)/$y;
$scX2 =intval($scX/2);
$scY2 =intval($scY/2);

for ($j = 0; $j < ($y); $j++) {
$sY = intval($j * $scY);
$y13 = $sY + $scY2;
for ($i = 0; $i < ($x); $i++) {
$sX = intval($i * $scX);
$x34 = $sX + $scX2;
$c1 = ImageColorsForIndex ($src, ImageColorAt ($src, $sX, $y13));
$c2 = ImageColorsForIndex ($src, ImageColorAt ($src, $sX, $sY));
$c3 = ImageColorsForIndex ($src, ImageColorAt ($src, $x34, $y13));
$c4 = ImageColorsForIndex ($src, ImageColorAt ($src, $x34, $sY));
$r = ($c1['red']+$c2['red']+$c3['red']+$c4['red'])/4;
$g = ($c1['green']+$c2['green']+$c3['green']+$c4['green'])/4;
$b = ($c1['blue']+$c2['blue']+$c3['blue']+$c4['blue'])/4;
ImageSetPixel ($dst, $i, $j, ImageColorClosest ($dst, $r, $g, $b));
}
}
return ($dst);
}
?>



  • 贊助網站       

    廣利不動產-新板特區指名度最高、值得您信賴的好房仲
    您的托付,廣利用心為您服務
    廣利不動產-板橋在地生根最實在--新板特區指名度最高、值得您信賴的好房仲
    完整房訊,房屋、店面熱門精選物件,廣利不動產 優質仲介,房屋租賃、買賣資訊透明,交易真安心!



  •  共 0 人回應

    姓名:
    佈告內容:
    其他選項: