summaryrefslogtreecommitdiff
path: root/doc/gm.patch
blob: a82f9b4983ab311cd316474aa77c712d969882dd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
diff -ur gm.old/coders/gif.c gm.new/coders/gif.c
--- gm.old/coders/gif.c	2009-12-16 10:50:03.000000000 -0800
+++ gm.new/coders/gif.c	2010-04-19 08:07:34.000000000 -0700
@@ -1022,6 +1022,8 @@
           image->colormap[i].red=ScaleCharToQuantum(*p++);
           image->colormap[i].green=ScaleCharToQuantum(*p++);
           image->colormap[i].blue=ScaleCharToQuantum(*p++);
+          if (i == opacity)
+              image->colormap[i].opacity=(Quantum) TransparentOpacity;
         }
         image->background_color=
           image->colormap[Min(background,image->colors-1)];
@@ -1048,6 +1050,8 @@
           image->colormap[i].red=ScaleCharToQuantum(*p++);
           image->colormap[i].green=ScaleCharToQuantum(*p++);
           image->colormap[i].blue=ScaleCharToQuantum(*p++);
+          if (i == opacity)
+            image->colormap[i].opacity=(Quantum) TransparentOpacity;
         }
         MagickFreeMemory(colormap);
       }
diff -ur gm.old/magick/image.c gm.new/magick/image.c
--- gm.old/magick/image.c	2010-03-02 13:46:44.000000000 -0800
+++ gm.new/magick/image.c	2010-04-19 08:20:33.000000000 -0700
@@ -1925,7 +1925,57 @@
   image->is_monochrome=IsMonochrome(image->background_color);
   return status;
 }
-
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%                                                                             %
+%                                                                             %
+%   S e t I m a g e C o l o r                                                 %
+%                                                                             %
+%                                                                             %
+%                                                                             %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%  SetImageColor() sets the red, green, blue and opacity components of each pixel to
+%  a specified level.
+%
+%  The format of the SetImageColor method is:
+%
+%      void SetImageColor(Image *image,const PixelPacket pixel)
+%
+%  A description of each parameter follows:
+%
+%    o image: The image.
+%
+%    o pixel: Set each pixel in the image to this pixel's color and transparency.
+%
+%
+*/
+MagickExport MagickPassFail SetImageColor(Image *image, const PixelPacket pixel)
+{
+  MagickPassFail
+    status;
+
+  assert(image != (Image *) NULL);
+  assert(image->signature == MagickSignature);
+  status=MagickPass;
+
+  image->matte=True;
+  image->colorspace=RGBColorspace;
+  image->storage_class=DirectClass;
+
+  status=PixelIterateMonoModify(SetImageColorCallBack,NULL,
+                                SetImageColorText,
+                                NULL,&pixel,0,0,
+                                image->columns,image->rows,
+                                image,&image->exception);
+
+  image->is_grayscale=IsGray(image->background_color);
+  image->is_monochrome=IsMonochrome(image->background_color);
+  return status;
+}
+
+
 /*
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 %                                                                             %
diff -ur gm.old/magick/image.h gm.new/magick/image.h
--- gm.old/magick/image.h	2010-03-01 13:15:28.000000000 -0800
+++ gm.new/magick/image.h	2010-04-19 07:27:27.000000000 -0700
@@ -1008,6 +1008,7 @@
   DisplayImages(const ImageInfo *image_info,Image *image),
   RemoveDefinitions(const ImageInfo *image_info,const char *options),
   SetImage(Image *,const Quantum),
+  SetImageColor(Image *,const PixelPacket),
   SetImageClipMask(Image *image,const Image *clip_mask),
   SetImageDepth(Image *,const unsigned long),
   SetImageInfo(ImageInfo *image_info,const unsigned int flags,ExceptionInfo *exception),
diff -ur gm.old/magick/transform.c gm.new/magick/transform.c
--- gm.old/magick/transform.c	2010-02-27 13:30:13.000000000 -0800
+++ gm.new/magick/transform.c	2010-04-19 07:28:35.000000000 -0700
@@ -317,6 +317,12 @@
   register const Image
     *next;
 
+  register long
+    i;
+  
+  MagickBool
+    found_transparency=False;
+
   /*
     Coalesce the image sequence.
   */
@@ -352,9 +358,19 @@
       }
       case BackgroundDispose:
       {
+        /* fill image with transparent color, if one exists */
         coalesce_image->next=CloneImage(coalesce_image,0,0,True,exception);
-        if (coalesce_image->next != (Image *) NULL)
-          (void) SetImage(coalesce_image->next,OpaqueOpacity);
+        if (coalesce_image->next != (Image *) NULL) {
+          for (i = 0; i < (long) coalesce_image->colors; i++) {
+            if (coalesce_image->colormap[i].opacity == TransparentOpacity) {
+              found_transparency = True;
+              (void) SetImageColor(coalesce_image->next,coalesce_image->colormap[i]);
+              break;
+            }
+          }
+          if (!found_transparency)
+            (void) SetImage(coalesce_image->next,OpaqueOpacity);
+        }
         break;
       }
       case PreviousDispose:
@@ -376,6 +392,7 @@
     (void) CompositeImage(coalesce_image,next->matte ? OverCompositeOp :
       CopyCompositeOp,next,next->page.x,next->page.y);
   }
+
   while (coalesce_image->previous != (Image *) NULL)
     coalesce_image=coalesce_image->previous;
   return(coalesce_image);