广告广告
  加入我的最爱 设为首页 风格修改
首页 首尾
 手机版   订阅   地图  繁体 
您是第 3661 个阅读者
 
发表文章 发表投票 回覆文章
  可列印版   加为IE收藏   收藏主题   上一主题 | 下一主题   
月光 手机
个人头像
个人文章 个人相簿 个人日记 个人地图
社区建设奖
头衔:看我代替月亮惩罚你!看我代替月亮惩罚你!
版主
级别: 版主 该用户目前不上站
版区: Unix-like, 网站架设
推文 x42 鲜花 x565
分享: 转寄此文章 Facebook Plurk Twitter 复制连结到剪贴簿 转换为繁体 转换为简体 载入图片
推文 x0
[PHP][原码] 高画质缩图函式
复制程式
<?php   
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);   
}   
?>



月光论坛
http://bbs.dj...com/


===================================
赞助本站 -- 刊登广告 -- 物超所值虚拟主机租用
献花 x0 回到顶端 [楼 主] From:台湾中华电信HINET | Posted:2007-05-14 20:34 |

首页  发表文章 发表投票 回覆文章
Powered by PHPWind v1.3.6
Copyright © 2003-04 PHPWind
Processed in 0.013678 second(s),query:15 Gzip disabled
本站由 瀛睿律师事务所 担任常年法律顾问 | 免责声明 | 本网站已依台湾网站内容分级规定处理 | 连络我们 | 访客留言