2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
13 % Read Constant Color Image. %
20 % Copyright 1999-2015 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/colorspace-private.h"
49 #include "MagickCore/exception.h"
50 #include "MagickCore/exception-private.h"
51 #include "MagickCore/image.h"
52 #include "MagickCore/image-private.h"
53 #include "MagickCore/list.h"
54 #include "MagickCore/magick.h"
55 #include "MagickCore/memory_.h"
56 #include "MagickCore/pixel.h"
57 #include "MagickCore/pixel-accessor.h"
58 #include "MagickCore/quantum-private.h"
59 #include "MagickCore/static.h"
60 #include "MagickCore/string_.h"
61 #include "MagickCore/module.h"
64 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
68 % R e a d X C I m a g e %
72 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 % ReadXCImage creates a constant image and initializes it to the
75 % X server color as specified by the filename. It allocates the memory
76 % necessary for the new Image structure and returns a pointer to the new
79 % The format of the ReadXCImage method is:
81 % Image *ReadXCImage(const ImageInfo *image_info,ExceptionInfo *exception)
83 % A description of each parameter follows:
87 % o image_info: the image info.
89 % o exception: return any errors or warnings in this structure.
92 static Image *ReadXCImage(const ImageInfo *image_info,ExceptionInfo *exception)
113 Initialize Image structure.
115 assert(image_info != (const ImageInfo *) NULL);
116 assert(image_info->signature == MagickSignature);
117 if (image_info->debug != MagickFalse)
118 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
119 image_info->filename);
120 assert(exception != (ExceptionInfo *) NULL);
121 assert(exception->signature == MagickSignature);
122 image=AcquireImage(image_info,exception);
123 if (image->columns == 0)
125 if (image->rows == 0)
127 status=SetImageExtent(image,image->columns,image->rows,exception);
128 if (status == MagickFalse)
129 return(DestroyImageList(image));
130 (void) CopyMagickString(image->filename,image_info->filename,MagickPathExtent);
131 if (*image_info->filename == '\0')
132 pixel=image->background_color;
135 status=QueryColorCompliance((char *) image_info->filename,AllCompliance,
137 if (status == MagickFalse)
139 image=DestroyImage(image);
140 return((Image *) NULL);
143 (void) SetImageColorspace(image,pixel.colorspace,exception);
144 image->alpha_trait=pixel.alpha_trait;
145 for (y=0; y < (ssize_t) image->rows; y++)
147 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
148 if (q == (Quantum *) NULL)
150 for (x=0; x < (ssize_t) image->columns; x++)
152 SetPixelViaPixelInfo(image,&pixel,q);
153 q+=GetPixelChannels(image);
155 if (SyncAuthenticPixels(image,exception) == MagickFalse)
158 return(GetFirstImageInList(image));
162 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
166 % R e g i s t e r X C I m a g e %
170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
172 % RegisterXCImage() adds attributes for the XC image format to
173 % the list of supported formats. The attributes include the image format
174 % tag, a method to read and/or write the format, whether the format
175 % supports the saving of more than one frame to the same file or blob,
176 % whether the format supports native in-memory I/O, and a brief
177 % description of the format.
179 % The format of the RegisterXCImage method is:
181 % size_t RegisterXCImage(void)
184 ModuleExport size_t RegisterXCImage(void)
189 entry=AcquireMagickInfo("XC","XC","Constant image uniform color");
190 entry->decoder=(DecodeImageHandler *) ReadXCImage;
191 entry->flags^=CoderAdjoinFlag;
192 entry->format_type=ImplicitFormatType;
193 entry->flags|=CoderRawSupportFlag;
194 entry->flags|=CoderEndianSupportFlag;
195 (void) RegisterMagickInfo(entry);
196 entry=AcquireMagickInfo("XC","CANVAS","Constant image uniform color");
197 entry->decoder=(DecodeImageHandler *) ReadXCImage;
198 entry->flags^=CoderAdjoinFlag;
199 entry->format_type=ImplicitFormatType;
200 entry->flags|=CoderRawSupportFlag;
201 entry->flags|=CoderEndianSupportFlag;
202 (void) RegisterMagickInfo(entry);
203 return(MagickImageCoderSignature);
207 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
211 % U n r e g i s t e r X C I m a g e %
215 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
217 % UnregisterXCImage() removes format registrations made by the
218 % XC module from the list of supported formats.
220 % The format of the UnregisterXCImage method is:
222 % UnregisterXCImage(void)
225 ModuleExport void UnregisterXCImage(void)
227 (void) UnregisterMagickInfo("CANVAS");
228 (void) UnregisterMagickInfo("XC");