From 10c933f3b858858e1a34d2ea3e0b642d60e1eae3 Mon Sep 17 00:00:00 2001 From: nicolaasuni Date: Mon, 23 Sep 2013 16:26:07 +0100 Subject: [PATCH] 6.0.033 (2013-09-23) - Bug fix related to PNG image transparency using GD library. --- CHANGELOG.TXT | 3 +++ README.TXT | 2 +- composer.json | 2 +- include/tcpdf_static.php | 2 +- tcpdf.php | 24 ++++++++++++------------ 5 files changed, 18 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.TXT b/CHANGELOG.TXT index 9b17617..7d7272c 100644 --- a/CHANGELOG.TXT +++ b/CHANGELOG.TXT @@ -1,3 +1,6 @@ +6.0.033 (2013-09-23) + - Bug fix related to PNG image transparency using GD library. + 6.0.032 (2013-09-23) - Bug #838 "Fatal error when imagick cannot handle the image, even though GD is available and can" was fixed. diff --git a/README.TXT b/README.TXT index 3c470cb..130a3d8 100644 --- a/README.TXT +++ b/README.TXT @@ -8,7 +8,7 @@ http://sourceforge.net/donate/index.php?group_id=128076 ------------------------------------------------------------ Name: TCPDF -Version: 6.0.032 +Version: 6.0.033 Release date: 2013-09-23 Author: Nicola Asuni diff --git a/composer.json b/composer.json index 96ab866..f728b3a 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "tecnick.com/tcpdf", - "version": "6.0.032", + "version": "6.0.033", "homepage": "http://www.tcpdf.org/", "type": "library", "description": "TCPDF is a PHP class for generating PDF documents.", diff --git a/include/tcpdf_static.php b/include/tcpdf_static.php index d2067e9..c30b97d 100644 --- a/include/tcpdf_static.php +++ b/include/tcpdf_static.php @@ -55,7 +55,7 @@ class TCPDF_STATIC { * Current TCPDF version. * @private static */ - private static $tcpdf_version = '6.0.032'; + private static $tcpdf_version = '6.0.033'; /** * String alias for total number of pages. diff --git a/tcpdf.php b/tcpdf.php index b33a1a1..9461842 100644 --- a/tcpdf.php +++ b/tcpdf.php @@ -1,7 +1,7 @@ * @package com.tecnick.tcpdf * @author Nicola Asuni - * @version 6.0.032 + * @version 6.0.033 */ // TCPDF configuration @@ -128,7 +128,7 @@ require_once(dirname(__FILE__).'/include/tcpdf_static.php'); * TCPDF project (http://www.tcpdf.org) has been originally derived in 2002 from the Public Domain FPDF class by Olivier Plathey (http://www.fpdf.org), but now is almost entirely rewritten.
* @package com.tecnick.tcpdf * @brief PHP class for generating PDF documents without requiring external extensions. - * @version 6.0.032 + * @version 6.0.033 * @author Nicola Asuni - info@tecnick.com */ class TCPDF { @@ -7216,7 +7216,8 @@ class TCPDF { for ($xpx = 0; $xpx < $wpx; ++$xpx) { for ($ypx = 0; $ypx < $hpx; ++$ypx) { $color = imagecolorat($img, $xpx, $ypx); - $alpha = $this->getGDgamma($color); // correct gamma + // get and correct gamma color + $alpha = $this->getGDgamma($img, $color); imagesetpixel($imgalpha, $xpx, $ypx, $alpha); } } @@ -7251,26 +7252,25 @@ class TCPDF { /** * Get the GD-corrected PNG gamma value from alpha color + * @param $img (int) GD image Resource ID. * @param $c (int) alpha color * @protected * @since 4.3.007 (2008-12-04) */ - protected function getGDgamma($c) { - if (!isset($this->gdgammacache["'".$c."'"])) { - // shifts off the first 24 bits (where 8x3 are used for each color), - // and returns the remaining 7 allocated bits (commonly used for alpha) - $alpha = ($c >> 24); + protected function getGDgamma($img, $c) { + if (!isset($this->gdgammacache['#'.$c])) { + $colors = imagecolorsforindex($img, $c); // GD alpha is only 7 bit (0 -> 127) - $alpha = (((127 - $alpha) / 127) * 255); + $this->gdgammacache['#'.$c] = (((127 - $colors['alpha']) / 127) * 255); // correct gamma - $this->gdgammacache["'".$c."'"] = (pow(($alpha / 255), 2.2) * 255); + $this->gdgammacache['#'.$c] = (pow(($this->gdgammacache['#'.$c] / 255), 2.2) * 255); // store the latest values on cache to improve performances if (count($this->gdgammacache) > 8) { // remove one element from the cache array array_shift($this->gdgammacache); } } - return $this->gdgammacache["'".$c."'"]; + return $this->gdgammacache['#'.$c]; } /**