2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
10 % N N UUU LLLLL LLLLL %
13 % Read/Write Image Of Uniform Color. %
20 % Copyright 1999-2018 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 % https://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-accessor.h"
57 #include "MagickCore/quantum-private.h"
58 #include "MagickCore/static.h"
59 #include "MagickCore/string_.h"
60 #include "MagickCore/module.h"
65 static MagickBooleanType
66 WriteNULLImage(const ImageInfo *,Image *,ExceptionInfo *);
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 == MagickCoreSignature);
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 == MagickCoreSignature);
127 image=AcquireImage(image_info,exception);
128 if (image->columns == 0)
130 if (image->rows == 0)
132 status=SetImageExtent(image,image->columns,image->rows,exception);
133 if (status == MagickFalse)
134 return(DestroyImageList(image));
135 ConformPixelInfo(image,&image->background_color,&background,exception);
136 image->alpha_trait=BlendPixelTrait;
137 background.alpha=(double) TransparentAlpha;
138 for (y=0; y < (ssize_t) image->rows; y++)
140 q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
141 if (q == (Quantum *) NULL)
143 for (x=0; x < (ssize_t) image->columns; x++)
145 SetPixelViaPixelInfo(image,&background,q);
146 q+=GetPixelChannels(image);
148 if (SyncAuthenticPixels(image,exception) == MagickFalse)
151 return(GetFirstImageInList(image));
155 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
159 % R e g i s t e r N U L L I m a g e %
163 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165 % RegisterNULLImage() adds attributes for the NULL image format to
166 % the list of supported formats. The attributes include the image format
167 % tag, a method to read and/or write the format, whether the format
168 % supports the saving of more than one frame to the same file or blob,
169 % whether the format supports native in-memory I/O, and a brief
170 % description of the format.
172 % The format of the RegisterNULLImage method is:
174 % size_t RegisterNULLImage(void)
177 ModuleExport size_t RegisterNULLImage(void)
182 entry=AcquireMagickInfo("NULL","NULL","Constant image of uniform color");
183 entry->decoder=(DecodeImageHandler *) ReadNULLImage;
184 entry->encoder=(EncodeImageHandler *) WriteNULLImage;
185 entry->flags^=CoderAdjoinFlag;
186 entry->format_type=ImplicitFormatType;
187 (void) RegisterMagickInfo(entry);
188 return(MagickImageCoderSignature);
192 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
196 % U n r e g i s t e r N U L L I m a g e %
200 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
202 % UnregisterNULLImage() removes format registrations made by the
203 % NULL module from the list of supported formats.
205 % The format of the UnregisterNULLImage method is:
207 % UnregisterNULLImage(void)
210 ModuleExport void UnregisterNULLImage(void)
212 (void) UnregisterMagickInfo("NULL");
216 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
220 % W r i t e N U L L I m a g e %
224 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226 % WriteNULLImage writes no output at all. It is useful when specified
227 % as an output format when profiling.
229 % The format of the WriteNULLImage method is:
231 % MagickBooleanType WriteNULLImage(const ImageInfo *image_info,
232 % Image *image,ExceptionInfo *exception)
234 % A description of each parameter follows.
236 % o image_info: the image info.
238 % o image: The image.
240 % o exception: return any errors or warnings in this structure.
243 static MagickBooleanType WriteNULLImage(const ImageInfo *image_info,
244 Image *image,ExceptionInfo *exception)
246 assert(image_info != (const ImageInfo *) NULL);
247 assert(image_info->signature == MagickCoreSignature);
248 assert(image != (Image *) NULL);
249 assert(image->signature == MagickCoreSignature);
250 assert(exception != (ExceptionInfo *) NULL);
251 if (image->debug != MagickFalse)
252 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);