Changeset 6920
- Timestamp:
- May 2, 2008, 7:00:45 AM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
OpenPNE/branches/work/ebihara/prj_renew_OpenPNE_Img/webapp/lib/OpenPNE/Img/Generator.php
r6919 r6920 113 113 114 114 $output_gdimg = imagecreatetruecolor($o_width, $o_height); 115 116 if (($this->getOutputFormat() == 'gif') || ($this->getOutputFormat() == 'png')) { 117 $trnprt_idx_s = imagecolortransparent($source_gdimg); 118 if ($trnprt_idx_s >= 0) { // 透過色が設定されている 119 imagetruecolortopalette($output_gdimg, true, 256); 120 121 // 入力画像から透明色取得 122 $trnprt_color = imagecolorsforindex($source_gdimg, $trnprt_idx_s); 123 124 // 出力画像に透明色設定 125 imagecolorset($source_gdimg, 0, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']); 126 imagefill($output_gdimg, 0, 0, 0); 127 imagecolortransparent($output_gdimg, 0); 128 } elseif ($this->getOutputFormat() == 'png') { // PNG-24 129 // アルファチャンネル情報を保存するには、アルファブレンディングを解除する必要がある 130 imagealphablending($output_gdimg, false); 131 imagesavealpha($output_gdimg, true); 132 133 // 透過色設定 134 $color = imagecolorallocatealpha($output_gdimg, 0, 0, 0, 127); 135 imagefill($output_gdimg, 0, 0, $color); 136 } 137 } 138 115 $this->setTransparentToOutputImage($output_gdimg, $source_gdimg); 139 116 imagecopyresampled($output_gdimg, $source_gdimg, 140 117 0, 0, 0, 0, $o_width, $o_height, $s_width, $s_height); 118 141 119 return $output_gdimg; 142 120 } … … 354 332 } 355 333 } 334 335 /** 336 * 入力画像から取得した透過情報を出力画像に適用する 337 */ 338 function setTransparentToOutputImage(&$output_gdimg, &$source_gdimg) 339 { 340 if ($this->getOutputFormat() != 'gif' && $this->getOutputFormat() != 'png') { 341 return null; 342 } 343 344 $trnprt_idx_s = imagecolortransparent($source_gdimg); 345 if ($trnprt_idx_s >= 0) { // 透過色が設定されている 346 imagetruecolortopalette($output_gdimg, true, 256); 347 348 // 入力画像から透明色取得 349 $trnprt_color = imagecolorsforindex($source_gdimg, $trnprt_idx_s); 350 351 // 出力画像に透明色設定 352 imagecolorset($source_gdimg, 0, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']); 353 imagefill($output_gdimg, 0, 0, 0); 354 imagecolortransparent($output_gdimg, 0); 355 } elseif ($this->getOutputFormat() == 'png') { // PNG-24 356 // アルファチャンネル情報を保存するには、アルファブレンディングを解除する必要がある 357 imagealphablending($output_gdimg, false); 358 imagesavealpha($output_gdimg, true); 359 360 // 透過色設定 361 $color = imagecolorallocatealpha($output_gdimg, 0, 0, 0, 127); 362 imagefill($output_gdimg, 0, 0, $color); 363 } 364 } 356 365 } 357 366
Note: See TracChangeset
for help on using the changeset viewer.