summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDerek Jones <derek.jones@ellislab.com>2008-05-12 17:08:35 +0200
committerDerek Jones <derek.jones@ellislab.com>2008-05-12 17:08:35 +0200
commit500fa6c3a934ac9d9f0a5c1ded5c00ad1709187f (patch)
treeddc1eccf593a16b2dae9c5c2756a5185f047f0c8
parentf7ba13da5fc004481cf057f47260f955d52e91ca (diff)
changed overlay_watermark() to check for an alpha value before applying the image to help support PNG-24s with alpha transparency
http://codeigniter.com/bug_tracker/bug/4506/
-rw-r--r--system/libraries/Image_lib.php25
-rw-r--r--user_guide/changelog.html3
2 files changed, 21 insertions, 7 deletions
diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php
index 0750b6454..4017afb13 100644
--- a/system/libraries/Image_lib.php
+++ b/system/libraries/Image_lib.php
@@ -943,10 +943,23 @@ class CI_Image_lib {
{
@imagealphablending($src_img, TRUE);
}
-
- // Set RGB values for text and shadow
- imagecolortransparent($wm_img, imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp));
- imagecopymerge($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height, $this->wm_opacity);
+
+ // Set RGB values for text and shadow
+ $rgba = imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp);
+ $alpha = ($rgba & 0x7F000000) >> 24;
+
+ // make a best guess as to whether we're dealing with an image with alpha transparency or no/binary transparency
+ if ($alpha > 0)
+ {
+ // copy the image directly, the image's alpha transparency being the sole determinant of blending
+ imagecopy($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height);
+ }
+ else
+ {
+ // set our RGB value from above to be transparent and merge the images with the specified opacity
+ imagecolortransparent($wm_img, imagecolorat($wm_img, $this->wm_x_transp, $this->wm_y_transp));
+ imagecopymerge($src_img, $wm_img, $x_axis, $y_axis, 0, 0, $wm_width, $wm_height, $this->wm_opacity);
+ }
// Output the image
if ($this->dynamic_output == TRUE)
@@ -1533,6 +1546,6 @@ class CI_Image_lib {
}
// END Image_lib Class
-
-/* End of file Image_lib.php */
+
+/* End of file Image_lib.php */
/* Location: ./system/libraries/Image_lib.php */ \ No newline at end of file
diff --git a/user_guide/changelog.html b/user_guide/changelog.html
index c5231655c..43905db3f 100644
--- a/user_guide/changelog.html
+++ b/user_guide/changelog.html
@@ -139,7 +139,8 @@ SVN Commit: not currently released</p>
<li>Fixed a bug in the table library that could cause identically constructed rows to be dropped (#3459).</li>
<li>Fixed a bug (#4206) in the Directory Helper where the directory resource was not being closed, and minor improvements.</li>
<li>Fixed a bug where SMTP emails were not having dot transformation performed on lines that begin with a dot.</li>
- <li>Fixed a bug in display_error() in the DB driver that was instantiating new Language and Exception objects, and not using the error heading.</li>
+ <li>Fixed a bug in display_error() in the DB driver that was instantiating new Language and Exception objects, and not using the error heading.</li>
+ <li>Fixed a bug (#4506) with overlay_watermark() in the Image library preventing support for PNG-24s with alpha transparency</li>
</ul>
<h2>Version 1.6.1</h2>