2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Read Constant Color Image. %
20 % Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
21 % dedicated to making software imaging solutions freely available. %
23 % You may not use this file except in compliance with the License. You may %
24 % obtain a copy of the License at %
26 % http://www.imagemagick.org/script/license.php %
28 % Unless required by applicable law or agreed to in writing, software %
29 % distributed under the License is distributed on an "AS IS" BASIS, %
30 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
31 % See the License for the specific language governing permissions and %
32 % limitations under the License. %
34 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42 #include "magick/studio.h"
43 #include "magick/blob.h"
44 #include "magick/blob-private.h"
45 #include "magick/cache.h"
46 #include "magick/color.h"
47 #include "magick/color-private.h"
48 #include "magick/exception.h"
49 #include "magick/exception-private.h"
50 #include "magick/image.h"
51 #include "magick/image-private.h"
52 #include "magick/list.h"
53 #include "magick/magick.h"
54 #include "magick/memory_.h"
55 #include "magick/pixel.h"
56 #include "magick/pixel-private.h"
57 #include "magick/quantum-private.h"
58 #include "magick/static.h"
59 #include "magick/string_.h"
60 #include "magick/module.h"
63 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
67 % R e a d X C I m a g e %
71 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 % ReadXCImage creates a constant image and initializes it to the
74 % X server color as specified by the filename. It allocates the memory
75 % necessary for the new Image structure and returns a pointer to the new
78 % The format of the ReadXCImage method is:
80 % Image *ReadXCImage(const ImageInfo *image_info,ExceptionInfo *exception)
82 % A description of each parameter follows:
86 % o image_info: the image info.
88 % o exception: return any errors or warnings in this structure.
91 static Image *ReadXCImage(const ImageInfo *image_info,ExceptionInfo *exception)
119 Initialize Image structure.
121 assert(image_info != (const ImageInfo *) NULL);
122 assert(image_info->signature == MagickSignature);
123 if (image_info->debug != MagickFalse)
124 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
125 image_info->filename);
126 assert(exception != (ExceptionInfo *) NULL);
127 assert(exception->signature == MagickSignature);
128 image=AcquireImage(image_info);
129 if (image->columns == 0)
131 if (image->rows == 0)
133 (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
134 status=QueryMagickColor((char *) image_info->filename,&color,exception);
135 if (status == MagickFalse)
137 image=DestroyImage(image);
138 return((Image *) NULL);
140 image->colorspace=color.colorspace;
141 image->matte=color.matte;
143 SetPixelPacket(image,&color,&pixel,&index);
144 for (y=0; y < (ssize_t) image->rows; y++)
146 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
147 if (q == (PixelPacket *) NULL)
149 for (x=0; x < (ssize_t) image->columns; x++)
151 if (image->colorspace == CMYKColorspace)
153 indexes=GetAuthenticIndexQueue(image);
154 for (x=0; x < (ssize_t) image->columns; x++)
155 SetIndexPixelComponent(indexes+x,index);
157 if (SyncAuthenticPixels(image,exception) == MagickFalse)
160 return(GetFirstImageInList(image));
164 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
168 % R e g i s t e r X C I m a g e %
172 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
174 % RegisterXCImage() adds attributes for the XC image format to
175 % the list of supported formats. The attributes include the image format
176 % tag, a method to read and/or write the format, whether the format
177 % supports the saving of more than one frame to the same file or blob,
178 % whether the format supports native in-memory I/O, and a brief
179 % description of the format.
181 % The format of the RegisterXCImage method is:
183 % size_t RegisterXCImage(void)
186 ModuleExport size_t RegisterXCImage(void)
191 entry=SetMagickInfo("XC");
192 entry->decoder=(DecodeImageHandler *) ReadXCImage;
193 entry->adjoin=MagickFalse;
194 entry->format_type=ImplicitFormatType;
195 entry->raw=MagickTrue;
196 entry->endian_support=MagickTrue;
197 entry->description=ConstantString("Constant image uniform color");
198 entry->module=ConstantString("XC");
199 (void) RegisterMagickInfo(entry);
200 entry=SetMagickInfo("CANVAS");
201 entry->decoder=(DecodeImageHandler *) ReadXCImage;
202 entry->adjoin=MagickFalse;
203 entry->format_type=ImplicitFormatType;
204 entry->raw=MagickTrue;
205 entry->endian_support=MagickTrue;
206 entry->description=ConstantString("Constant image uniform color");
207 entry->module=ConstantString("XC");
208 (void) RegisterMagickInfo(entry);
209 return(MagickImageCoderSignature);
213 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
217 % U n r e g i s t e r X C I m a g e %
221 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
223 % UnregisterXCImage() removes format registrations made by the
224 % XC module from the list of supported formats.
226 % The format of the UnregisterXCImage method is:
228 % UnregisterXCImage(void)
231 ModuleExport void UnregisterXCImage(void)
233 (void) UnregisterMagickInfo("CANVAS");
234 (void) UnregisterMagickInfo("XC");