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

#2516 透過png画像の背景が真っ黒になってしまう
スペース調整

File:
1 edited

Legend:

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

    r23444 r23445  
    228228     
    229229            // png形式     
    230             case "3":  
    231  
     230            case "3": 
    232231                $src_im = imageCreateFromPNG($path); 
    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); 
     232                $colortransparent = imagecolortransparent($src_im); 
     233                $has_alpha = ord(file_get_contents($path, false, null, 25, 1)) & 0x04; 
     234                if ($colortransparent > -1 || $has_alpha) { 
     235                    $dst_im = $imagecreate($re_size[0], $re_size[1]); 
     236                    // アルファチャンネルが存在する場合はそちらを使用する 
     237                if ($has_alpha) { 
     238                    imagealphablending($dst_im, false); 
     239                    imagesavealpha($dst_im, true); 
     240                } 
     241                    imagepalettecopy($dst_im, $src_im); 
     242                    imagefill($dst_im, 0, 0, $colortransparent); 
     243                    imagecolortransparent($dst_im, $colortransparent); 
     244                    imagecopyresized($dst_im,$src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); 
     245                } else { 
     246                    $dst_im = $imagecreate($re_size[0], $re_size[1]); 
     247                    imagecopyresized($dst_im,$src_im, 0, 0, 0, 0, $re_size[0], $re_size[1], $size[0], $size[1]); 
     248 
     249                    (imagecolorstotal($src_im) == 0) ? $colortotal = 65536 : $colortotal = imagecolorstotal($src_im); 
     250 
     251                    imagetruecolortopalette($dst_im, true, $colortotal); 
    253252                } 
    254253                 
Note: See TracChangeset for help on using the changeset viewer.