2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Read Constant Color Image. %
20 % Copyright 1999-2012 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 "MagickCore/studio.h"
43 #include "MagickCore/blob.h"
44 #include "MagickCore/blob-private.h"
45 #include "MagickCore/cache.h"
46 #include "MagickCore/color.h"
47 #include "MagickCore/color-private.h"
48 #include "MagickCore/exception.h"
49 #include "MagickCore/exception-private.h"
50 #include "MagickCore/image.h"
51 #include "MagickCore/image-private.h"
52 #include "MagickCore/list.h"
53 #include "MagickCore/magick.h"
54 #include "MagickCore/memory_.h"
55 #include "MagickCore/pixel.h"
56 #include "MagickCore/pixel-accessor.h"
57 #include "MagickCore/quantum-private.h"
58 #include "MagickCore/static.h"
59 #include "MagickCore/string_.h"
60 #include "MagickCore/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)
112 Initialize Image structure.
114 assert(image_info != (const ImageInfo *) NULL);
115 assert(image_info->signature == MagickSignature);
116 if (image_info->debug != MagickFalse)
117 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
118 image_info->filename);
119 assert(exception != (ExceptionInfo *) NULL);
120 assert(exception->signature == MagickSignature);
121 image=AcquireImage(image_info,exception);
122 if (image->columns == 0)
124 if (image->rows == 0)
126 (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
127 status=QueryColorCompliance((char *) image_info->filename,AllCompliance,
129 if (status == MagickFalse)
131 image=DestroyImage(image);
132 return((Image *) NULL);
134 SetImageColorspace(image,pixel.colorspace,exception);
135 image->matte=pixel.matte;
136 for (y=0; y < (ssize_t) image->rows; y++)
138 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
139 if (q == (Quantum *) NULL)
141 for (x=0; x < (ssize_t) image->columns; x++)
143 SetPixelInfoPixel(image,&pixel,q);
144 q+=GetPixelChannels(image);
146 if (SyncAuthenticPixels(image,exception) == MagickFalse)
149 return(GetFirstImageInList(image));
153 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157 % R e g i s t e r X C I m a g e %
161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
163 % RegisterXCImage() adds attributes for the XC image format to
164 % the list of supported formats. The attributes include the image format
165 % tag, a method to read and/or write the format, whether the format
166 % supports the saving of more than one frame to the same file or blob,
167 % whether the format supports native in-memory I/O, and a brief
168 % description of the format.
170 % The format of the RegisterXCImage method is:
172 % size_t RegisterXCImage(void)
175 ModuleExport size_t RegisterXCImage(void)
180 entry=SetMagickInfo("XC");
181 entry->decoder=(DecodeImageHandler *) ReadXCImage;
182 entry->adjoin=MagickFalse;
183 entry->format_type=ImplicitFormatType;
184 entry->raw=MagickTrue;
185 entry->endian_support=MagickTrue;
186 entry->description=ConstantString("Constant image uniform color");
187 entry->module=ConstantString("XC");
188 (void) RegisterMagickInfo(entry);
189 entry=SetMagickInfo("CANVAS");
190 entry->decoder=(DecodeImageHandler *) ReadXCImage;
191 entry->adjoin=MagickFalse;
192 entry->format_type=ImplicitFormatType;
193 entry->raw=MagickTrue;
194 entry->endian_support=MagickTrue;
195 entry->description=ConstantString("Constant image uniform color");
196 entry->module=ConstantString("XC");
197 (void) RegisterMagickInfo(entry);
198 return(MagickImageCoderSignature);
202 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
206 % U n r e g i s t e r X C I m a g e %
210 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
212 % UnregisterXCImage() removes format registrations made by the
213 % XC module from the list of supported formats.
215 % The format of the UnregisterXCImage method is:
217 % UnregisterXCImage(void)
220 ModuleExport void UnregisterXCImage(void)
222 (void) UnregisterMagickInfo("CANVAS");
223 (void) UnregisterMagickInfo("XC");