summaryrefslogtreecommitdiff
path: root/src/gd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gd.c')
-rw-r--r--src/gd.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/gd.c b/src/gd.c
index 4c1c3b6..db96cc9 100644
--- a/src/gd.c
+++ b/src/gd.c
@@ -895,19 +895,27 @@ BGD_DECLARE(void) gdImageColorDeallocate (gdImagePtr im, int color)
*/
BGD_DECLARE(void) gdImageColorTransparent (gdImagePtr im, int color)
{
- if (color < 0) {
+ // Reset ::transparent
+ if (color == -1) {
+ im->transparent = -1;
return;
}
- if (!im->trueColor) {
- if (color >= gdMaxColors) {
- return;
- }
- if (im->transparent != -1) {
- im->alpha[im->transparent] = gdAlphaOpaque;
- }
- im->alpha[color] = gdAlphaTransparent;
+ if (color < -1) {
+ return;
+ }
+
+ if (im->trueColor) {
+ im->transparent = color;
+ return;
+ }
+
+ // Palette Image
+ if (color >= gdMaxColors) {
+ return;
}
+ im->alpha[im->transparent] = gdAlphaOpaque;
+ im->alpha[color] = gdAlphaTransparent;
im->transparent = color;
}