Coverage Report

Created: 2026-06-07 07:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/imagemagick/coders/null.c
Line
Count
Source
1
/*
2
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3
%                                                                             %
4
%                                                                             %
5
%                                                                             %
6
%                        N   N  U   U  L      L                               %
7
%                        NN  N  U   U  L      L                               %
8
%                        N N N  U   U  L      L                               %
9
%                        N  NN  U   U  L      L                               %
10
%                        N   N   UUU   LLLLL  LLLLL                           %
11
%                                                                             %
12
%                                                                             %
13
%                    Read/Write Image Of Uniform Color.                       %
14
%                                                                             %
15
%                              Software Design                                %
16
%                                   Cristy                                    %
17
%                                 July 1992                                   %
18
%                                                                             %
19
%                                                                             %
20
%  Copyright @ 1999 ImageMagick Studio LLC, a non-profit organization         %
21
%  dedicated to making software imaging solutions freely available.           %
22
%                                                                             %
23
%  You may not use this file except in compliance with the License.  You may  %
24
%  obtain a copy of the License at                                            %
25
%                                                                             %
26
%    https://imagemagick.org/license/                                         %
27
%                                                                             %
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.                                             %
33
%                                                                             %
34
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
35
%
36
%
37
*/
38

39
/*
40
  Include declarations.
41
*/
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"
61

62
/*
63
  Forward declarations.
64
*/
65
static MagickBooleanType
66
  WriteNULLImage(const ImageInfo *,Image *,ExceptionInfo *)
67
    magick_attribute((__pure__));
68

69
/*
70
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
71
%                                                                             %
72
%                                                                             %
73
%                                                                             %
74
%   R e a d N U L L I m a g e                                                 %
75
%                                                                             %
76
%                                                                             %
77
%                                                                             %
78
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
79
%
80
%  ReadNULLImage creates a constant image and initializes it to the
81
%  X server color as specified by the filename.  It allocates the memory
82
%  necessary for the new Image structure and returns a pointer to the new
83
%  image.
84
%
85
%  The format of the ReadNULLImage method is:
86
%
87
%      Image *ReadNULLImage(const ImageInfo *image_info,
88
%        ExceptionInfo *exception)
89
%
90
%  A description of each parameter follows:
91
%
92
%    o image_info: the image info.
93
%
94
%    o exception: return any errors or warnings in this structure.
95
%
96
*/
97
static Image *ReadNULLImage(const ImageInfo *image_info,
98
  ExceptionInfo *exception)
99
367
{
100
367
  Image
101
367
    *image;
102
103
367
  MagickBooleanType
104
367
    status;
105
106
367
  PixelInfo
107
367
    background;
108
109
367
  ssize_t
110
367
    x;
111
112
367
  Quantum
113
367
    *q;
114
115
367
  ssize_t
116
367
    y;
117
118
  /*
119
    Initialize Image structure.
120
  */
121
367
  assert(image_info != (const ImageInfo *) NULL);
122
367
  assert(image_info->signature == MagickCoreSignature);
123
367
  assert(exception != (ExceptionInfo *) NULL);
124
367
  assert(exception->signature == MagickCoreSignature);
125
367
  if (IsEventLogging() != MagickFalse)
126
0
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
127
0
      image_info->filename);
128
367
  image=AcquireImage(image_info,exception);
129
367
  if (image->columns == 0)
130
34
    image->columns=1;
131
367
  if (image->rows == 0)
132
70
    image->rows=1;
133
367
  image->alpha_trait=BlendPixelTrait;
134
367
  status=SetImageExtent(image,image->columns,image->rows,exception);
135
367
  if (status == MagickFalse)
136
1
    return(DestroyImageList(image));
137
366
  ConformPixelInfo(image,&image->background_color,&background,exception);
138
366
  background.alpha=(double) TransparentAlpha;
139
35.3k
  for (y=0; y < (ssize_t) image->rows; y++)
140
34.9k
  {
141
34.9k
    q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
142
34.9k
    if (q == (Quantum *) NULL)
143
0
      break;
144
5.63M
    for (x=0; x < (ssize_t) image->columns; x++)
145
5.59M
    {
146
5.59M
      SetPixelViaPixelInfo(image,&background,q);
147
5.59M
      q+=(ptrdiff_t) GetPixelChannels(image);
148
5.59M
    }
149
34.9k
    if (SyncAuthenticPixels(image,exception) == MagickFalse)
150
0
      break;
151
34.9k
  }
152
366
  return(GetFirstImageInList(image));
153
367
}
154

155
/*
156
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
157
%                                                                             %
158
%                                                                             %
159
%                                                                             %
160
%   R e g i s t e r N U L L I m a g e                                         %
161
%                                                                             %
162
%                                                                             %
163
%                                                                             %
164
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
165
%
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.
172
%
173
%  The format of the RegisterNULLImage method is:
174
%
175
%      size_t RegisterNULLImage(void)
176
%
177
*/
178
ModuleExport size_t RegisterNULLImage(void)
179
8
{
180
8
  MagickInfo
181
8
    *entry;
182
183
8
  entry=AcquireMagickInfo("NULL","NULL","Constant image of uniform color");
184
8
  entry->decoder=(DecodeImageHandler *) ReadNULLImage;
185
8
  entry->encoder=(EncodeImageHandler *) WriteNULLImage;
186
8
  entry->flags^=CoderAdjoinFlag;
187
8
  entry->format_type=ImplicitFormatType;
188
8
  (void) RegisterMagickInfo(entry);
189
8
  return(MagickImageCoderSignature);
190
8
}
191

192
/*
193
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
194
%                                                                             %
195
%                                                                             %
196
%                                                                             %
197
%   U n r e g i s t e r N U L L I m a g e                                     %
198
%                                                                             %
199
%                                                                             %
200
%                                                                             %
201
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
202
%
203
%  UnregisterNULLImage() removes format registrations made by the
204
%  NULL module from the list of supported formats.
205
%
206
%  The format of the UnregisterNULLImage method is:
207
%
208
%      UnregisterNULLImage(void)
209
%
210
*/
211
ModuleExport void UnregisterNULLImage(void)
212
0
{
213
0
  (void) UnregisterMagickInfo("NULL");
214
0
}
215

216
/*
217
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
218
%                                                                             %
219
%                                                                             %
220
%                                                                             %
221
%   W r i t e N U L L I m a g e                                               %
222
%                                                                             %
223
%                                                                             %
224
%                                                                             %
225
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
226
%
227
%  WriteNULLImage writes no output at all. It is useful when specified
228
%  as an output format when profiling.
229
%
230
%  The format of the WriteNULLImage method is:
231
%
232
%      MagickBooleanType WriteNULLImage(const ImageInfo *image_info,
233
%        Image *image,ExceptionInfo *exception)
234
%
235
%  A description of each parameter follows.
236
%
237
%    o image_info: the image info.
238
%
239
%    o image:  The image.
240
%
241
%    o exception: return any errors or warnings in this structure.
242
%
243
*/
244
static MagickBooleanType WriteNULLImage(const ImageInfo *image_info,
245
  Image *image,ExceptionInfo *exception)
246
0
{
247
0
  assert(image_info != (const ImageInfo *) NULL);
248
0
  assert(image_info->signature == MagickCoreSignature);
249
0
  assert(image != (Image *) NULL);
250
0
  assert(image->signature == MagickCoreSignature);
251
0
  assert(exception != (ExceptionInfo *) NULL);
252
0
  if (IsEventLogging() != MagickFalse)
253
0
    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
254
0
  (void) image_info;
255
0
  (void) exception;
256
0
  return(MagickTrue);
257
0
}