2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 % N N UUU LLLLL LLLLL %
13 % Read/Write Image Of Uniform Color. %
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/colorspace-private.h"
49 #include "magick/exception.h"
50 #include "magick/exception-private.h"
51 #include "magick/image.h"
52 #include "magick/image-private.h"
53 #include "magick/list.h"
54 #include "magick/magick.h"
55 #include "magick/memory_.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"
65 static MagickBooleanType
66 WriteNULLImage(const ImageInfo *,Image *);
69 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
73 % R e a d N U L L I m a g e %
77 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79 % ReadNULLImage creates a constant image and initializes it to the
80 % X server color as specified by the filename. It allocates the memory
81 % necessary for the new Image structure and returns a pointer to the new
84 % The format of the ReadNULLImage method is:
86 % Image *ReadNULLImage(const ImageInfo *image_info,
87 % ExceptionInfo *exception)
89 % A description of each parameter follows:
91 % o image_info: the image info.
93 % o exception: return any errors or warnings in this structure.
96 static Image *ReadNULLImage(const ImageInfo *image_info,
97 ExceptionInfo *exception)
118 Initialize Image structure.
120 assert(image_info != (const ImageInfo *) NULL);
121 assert(image_info->signature == MagickSignature);
122 if (image_info->debug != MagickFalse)
123 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
124 image_info->filename);
125 assert(exception != (ExceptionInfo *) NULL);
126 assert(exception->signature == MagickSignature);
127 image=AcquireImage(image_info);
128 if (image->columns == 0)
130 if (image->rows == 0)
132 image->matte=MagickTrue;
133 GetMagickPixelPacket(image,&background);
134 background.opacity=(MagickRealType) TransparentOpacity;
135 if (image->colorspace == CMYKColorspace)
136 ConvertRGBToCMYK(&background);
137 for (y=0; y < (ssize_t) image->rows; y++)
139 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
140 if (q == (PixelPacket *) NULL)
142 indexes=GetAuthenticIndexQueue(image);
143 for (x=0; x < (ssize_t) image->columns; x++)
145 SetPixelPacket(image,&background,q,indexes);
149 if (SyncAuthenticPixels(image,exception) == MagickFalse)
152 return(GetFirstImageInList(image));
156 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
160 % R e g i s t e r N U L L I m a g e %
164 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
166 % RegisterNULLImage() adds attributes for the NULL image format to
167 % the list of supported formats. The attributes include the image format
168 % tag, a method to read and/or write the format, whether the format
169 % supports the saving of more than one frame to the same file or blob,
170 % whether the format supports native in-memory I/O, and a brief
171 % description of the format.
173 % The format of the RegisterNULLImage method is:
175 % size_t RegisterNULLImage(void)
178 ModuleExport size_t RegisterNULLImage(void)
183 entry=SetMagickInfo("NULL");
184 entry->decoder=(DecodeImageHandler *) ReadNULLImage;
185 entry->encoder=(EncodeImageHandler *) WriteNULLImage;
186 entry->adjoin=MagickFalse;
187 entry->format_type=ImplicitFormatType;
188 entry->description=ConstantString("Constant image of uniform color");
189 entry->module=ConstantString("NULL");
190 (void) RegisterMagickInfo(entry);
191 return(MagickImageCoderSignature);
195 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
199 % U n r e g i s t e r N U L L I m a g e %
203 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
205 % UnregisterNULLImage() removes format registrations made by the
206 % NULL module from the list of supported formats.
208 % The format of the UnregisterNULLImage method is:
210 % UnregisterNULLImage(void)
213 ModuleExport void UnregisterNULLImage(void)
215 (void) UnregisterMagickInfo("NULL");
219 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
223 % W r i t e N U L L I m a g e %
227 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
229 % WriteNULLImage writes no output at all. It is useful when specified
230 % as an output format when profiling.
232 % The format of the WriteNULLImage method is:
234 % MagickBooleanType WriteNULLImage(const ImageInfo *image_info,
237 % A description of each parameter follows.
239 % o image_info: the image info.
241 % o image: The image.
244 static MagickBooleanType WriteNULLImage(const ImageInfo *image_info,
247 assert(image_info != (const ImageInfo *) NULL);
248 assert(image_info->signature == MagickSignature);
249 assert(image != (Image *) NULL);
250 assert(image->signature == MagickSignature);
251 if (image->debug != MagickFalse)
252 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);