[BUGFIX] backColor transparent causes black background or flickering
authorGeorg Grossberger <garfieldius67@gmail.com>
Fri, 17 Feb 2012 10:17:51 +0000 (11:17 +0100)
committerJigal van Hemert <jigal@xs4all.nl>
Tue, 7 Aug 2012 05:21:11 +0000 (07:21 +0200)
When a GIFBUILDER object has set its backColor option to transparent,
the background may be black when adding a IMAGE object to it, and inner
areas of TEXT elements may be completly transparent, ignoring the
transparency by underlying elements.

This patch, removes the "imagealphablending" function calls, which
caused the latter issue and adds an additional check to the
tslib_stdGraphic::imagecopyresized method to prevent useage of the
imagecopyresized_fix workaround when working with transparency, as
it is responsible for the black background.

Backwards compatibility is not affected, since upgraded systems will
not have a backColor=transparent setting, thus have the property
saveAlphaLayer set to FALSE in any case.

Change-Id: I938802373b9afea03cb49a5e034d82bec0d6c664
Fixes: #32781
Releases: 6.0, 4.7, 4.6
Reviewed-on: http://review.typo3.org/9070
Reviewed-by: Wouter Wolters
Reviewed-by: Jigal van Hemert
Tested-by: Jigal van Hemert
t3lib/class.t3lib_stdgraphic.php
typo3/sysext/cms/tslib/class.tslib_gifbuilder.php

index 3235033..fc49ad6 100644 (file)
@@ -297,7 +297,6 @@ class t3lib_stdGraphic {
 
                                        // Preserve alpha transparency
                                if ($this->saveAlphaLayer) {
-                                       imagealphablending($destImg, FALSE);
                                        imagesavealpha($destImg, TRUE);
                                        $Bcolor = imagecolorallocatealpha($destImg, 0, 0, 0, 127);
                                        imagefill($destImg, 0, 0, $Bcolor);
@@ -315,7 +314,6 @@ class t3lib_stdGraphic {
                                $cpImg = $this->imageCreateFromFile($BBmask[3]);
                                $destImg = imagecreatetruecolor($w, $h);
                                if ($this->saveAlphaLayer) {
-                                       imagealphablending($destImg, FALSE);
                                        imagesavealpha($destImg, TRUE);
                                        $Bcolor = imagecolorallocatealpha($destImg, 0, 0, 0, 127);
                                        imagefill($destImg, 0, 0, $Bcolor);
@@ -465,7 +463,7 @@ class t3lib_stdGraphic {
         * @see t3lib_iconWorks::imagecopyresized()
         */
        function imagecopyresized(&$dstImg, $srcImg, $dstX, $dstY, $srcX, $srcY, $dstWidth, $dstHeight, $srcWidth, $srcHeight) {
-               if ($this->imagecopyresized_fix) {
+               if ($this->imagecopyresized_fix && !$this->saveAlphaLayer) {
                                // Make true color image
                        $tmpImg = imagecreatetruecolor(imagesx($dstImg), imagesy($dstImg));
                                // Copy the source image onto that
@@ -2899,7 +2897,6 @@ class t3lib_stdGraphic {
                                if (function_exists('imagecreatefrompng')) {
                                        $imageHandle = imageCreateFromPng($sourceImg);
                                        if ($this->saveAlphaLayer) {
-                                               imagealphablending($imageHandle, FALSE);
                                                imagesavealpha($imageHandle, TRUE);
                                        }
                                        return $imageHandle;
@@ -2997,4 +2994,4 @@ class t3lib_stdGraphic {
        }
 }
 
-?>
\ No newline at end of file
+?>
index 057ed58..3aeb29c 100644 (file)
@@ -365,7 +365,6 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                        && (empty($this->setup['format']) || $this->setup['format'] === 'png')) {
 
                                // Set transparency properties
-                       imagealphablending($this->im, FALSE);
                        imagesavealpha($this->im, TRUE);
 
                                // Fill with a transparent background
@@ -837,4 +836,4 @@ class tslib_gifBuilder extends t3lib_stdGraphic {
                return $maximum;
        }
 }
-?>
\ No newline at end of file
+?>