Subject: | Could not get alpha value for some color index |
There is no way to get alpha value for specified index in the color palette. GD's
native method for this goal is gdImageAlpha(img, color). A patch is included.
Subject: | GD-2.41-alpha.patch |
diff -urN GD-2.41/GD.pm GD-2.41-alpha/GD.pm
--- GD-2.41/GD.pm 2008-08-07 23:14:26.000000000 +0400
+++ GD-2.41-alpha/GD.pm 2008-09-01 21:11:20.773355123 +0400
@@ -680,7 +680,8 @@
This returns the color table index underneath the specified
point. It can be combined with rgb()
-to obtain the rgb color underneath the pixel.
+to obtain the rgb color underneath the pixel and alpha() to obtain
+the alpha value of the pixel.
Example:
@@ -696,6 +697,14 @@
@RGB = $myImage->rgb($peachy);
+=item B<$alpha = $image-E<gt>alpha($index)>
+
+This returns the alpha value of the specified color index.
+
+Example:
+
+ $alpha = $myImage->alpha($peachy);
+
=item B<$image-E<gt>transparent($colorIndex)>
This marks the color at the specified index as being transparent.
diff -urN GD-2.41/GD.xs GD-2.41-alpha/GD.xs
--- GD-2.41/GD.xs 2006-08-22 03:48:18.000000000 +0400
+++ GD-2.41-alpha/GD.xs 2008-09-01 20:49:22.271022533 +0400
@@ -1191,6 +1191,18 @@
}
int
+gdalpha(image,color)
+ GD::Image image
+ int color
+ PROTOTYPE: $$
+ CODE:
+ {
+ RETVAL=gdImageAlpha(image,color);
+ }
+ OUTPUT:
+ RETVAL
+
+int
gdboundsSafe(image,x,y)
GD::Image image
int x