Ignore:
Timestamp:
2014/05/26 18:38:07 (10 years ago)
Author:
yomoro
Message:

#2516 透過png画像の背景が真っ黒になってしまう
snitta さんのパッチを当てて動作確認し、問題ない事を確認しました。
コミットさせていただきます。

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/version-2_13-dev/data/module/gdthumb.php

    r20628 r23444  
    231231 
    232232                $src_im = imageCreateFromPNG($path); 
    233                  
    234                 $colortransparent = imagecolortransparent($src_im); 
    235                 if ($colortransparent > -1) { 
    236                     $dst_im = $imagecreate($re_size[0], $re_size[1]); 
    237                     imagepalettecopy($dst_im, $src_im); 
    238                     imagefill($dst_im, 0, 0, $colortransparent); 
    239                     imagecolortransparent($dst_im, $colortransparent); 
    240                     imagecopyresized($dst_im,$src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); 
    241                 } else {                 
    242                     $dst_im = $imagecreate($re_size[0], $re_size[1]); 
    243                     imagecopyresized($dst_im,$src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); 
    244                      
    245                     (imagecolorstotal($src_im) == 0) ? $colortotal = 65536 : $colortotal = imagecolorstotal($src_im); 
    246                      
    247                     imagetruecolortopalette($dst_im, true, $colortotal); 
    248                 } 
     233                $colortransparent = imagecolortransparent($src_im); 
     234                $has_alpha = ord(file_get_contents($path, false, null, 25, 1)) & 0x04; 
     235                if ($colortransparent > -1 || $has_alpha) { 
     236                    $dst_im = $imagecreate($re_size[0], $re_size[1]); 
     237                    // アルファチャンネルが存在する場合はそちらを使用する 
     238                    if ($has_alpha) { 
     239                        imagealphablending($dst_im, false); 
     240                        imagesavealpha($dst_im, true); 
     241                    } 
     242                    imagepalettecopy($dst_im, $src_im); 
     243                    imagefill($dst_im, 0, 0, $colortransparent); 
     244                    imagecolortransparent($dst_im, $colortransparent); 
     245                    imagecopyresized($dst_im,$src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); 
     246                } else { 
     247                    $dst_im = $imagecreate($re_size[0], $re_size[1]); 
     248                    imagecopyresized($dst_im,$src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); 
     249 
     250                    (imagecolorstotal($src_im) == 0) ? $colortotal = 65536 : $colortotal = imagecolorstotal($src_im); 
     251 
     252                    imagetruecolortopalette($dst_im, true, $colortotal); 
     253                } 
    249254                 
    250255                // 画像出力 
Note: See TracChangeset for help on using the changeset viewer.