/src/imagemagick/coders/tile.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
3 | | % % |
4 | | % % |
5 | | % % |
6 | | % TTTTT IIIII L EEEEE % |
7 | | % T I L E % |
8 | | % T I L EEE % |
9 | | % T I L E % |
10 | | % T IIIII LLLLL EEEEE % |
11 | | % % |
12 | | % % |
13 | | % Return A Tiled Image Using Texture. % |
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/script/license.php % |
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/constitute.h" |
46 | | #include "MagickCore/exception.h" |
47 | | #include "MagickCore/exception-private.h" |
48 | | #include "MagickCore/image.h" |
49 | | #include "MagickCore/image-private.h" |
50 | | #include "MagickCore/list.h" |
51 | | #include "MagickCore/magick.h" |
52 | | #include "MagickCore/memory_.h" |
53 | | #include "MagickCore/monitor.h" |
54 | | #include "MagickCore/monitor-private.h" |
55 | | #include "MagickCore/quantum-private.h" |
56 | | #include "MagickCore/static.h" |
57 | | #include "MagickCore/string_.h" |
58 | | #include "MagickCore/module.h" |
59 | | |
60 | | /* |
61 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
62 | | % % |
63 | | % % |
64 | | % % |
65 | | % R e a d T I L E I m a g e % |
66 | | % % |
67 | | % % |
68 | | % % |
69 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
70 | | % |
71 | | % ReadTILEImage tiles a texture on an image. It allocates the |
72 | | % memory necessary for the new Image structure and returns a pointer to the |
73 | | % new image. |
74 | | % |
75 | | % The format of the ReadTILEImage method is: |
76 | | % |
77 | | % Image *ReadTILEImage(const ImageInfo *image_info, |
78 | | % ExceptionInfo *exception) |
79 | | % |
80 | | % A description of each parameter follows: |
81 | | % |
82 | | % o image_info: the image info. |
83 | | % |
84 | | % o exception: return any errors or warnings in this structure. |
85 | | % |
86 | | */ |
87 | | static Image *ReadTILEImage(const ImageInfo *image_info, |
88 | | ExceptionInfo *exception) |
89 | 27 | { |
90 | 27 | Image |
91 | 27 | *image, |
92 | 27 | *tile_image; |
93 | | |
94 | 27 | ImageInfo |
95 | 27 | *read_info; |
96 | | |
97 | 27 | MagickBooleanType |
98 | 27 | status; |
99 | | |
100 | | /* |
101 | | Initialize Image structure. |
102 | | */ |
103 | 27 | assert(image_info != (const ImageInfo *) NULL); |
104 | 27 | assert(image_info->signature == MagickCoreSignature); |
105 | 27 | assert(exception != (ExceptionInfo *) NULL); |
106 | 27 | assert(exception->signature == MagickCoreSignature); |
107 | 27 | if (IsEventLogging() != MagickFalse) |
108 | 0 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
109 | 0 | image_info->filename); |
110 | 27 | image=AcquireImage(image_info,exception); |
111 | 27 | if ((image->columns == 0) || (image->rows == 0)) |
112 | 27 | ThrowReaderException(OptionError,"MustSpecifyImageSize"); |
113 | 0 | if (*image_info->filename == '\0') |
114 | 0 | ThrowReaderException(OptionError,"MustSpecifyAnImageName"); |
115 | 0 | status=SetImageExtent(image,image->columns,image->rows,exception); |
116 | 0 | if (status == MagickFalse) |
117 | 0 | return(DestroyImageList(image)); |
118 | 0 | read_info=CloneImageInfo(image_info); |
119 | 0 | SetImageInfoBlob(read_info,(void *) NULL,0); |
120 | 0 | *read_info->magick='\0'; |
121 | 0 | if (read_info->size != (char *) NULL) |
122 | 0 | read_info->size=DestroyString(read_info->size); |
123 | 0 | tile_image=ReadImage(read_info,exception); |
124 | 0 | read_info=DestroyImageInfo(read_info); |
125 | 0 | if (tile_image == (Image *) NULL) |
126 | 0 | return(DestroyImageList(image)); |
127 | 0 | image->colorspace=tile_image->colorspace; |
128 | 0 | image->alpha_trait=tile_image->alpha_trait; |
129 | 0 | (void) CopyMagickString(image->filename,image_info->filename, |
130 | 0 | MagickPathExtent); |
131 | 0 | if (LocaleCompare(tile_image->magick,"PATTERN") == 0) |
132 | 0 | { |
133 | 0 | tile_image->tile_offset.x=0; |
134 | 0 | tile_image->tile_offset.y=0; |
135 | 0 | } |
136 | 0 | (void) TextureImage(image,tile_image,exception); |
137 | 0 | tile_image=DestroyImage(tile_image); |
138 | 0 | if ((image->colorspace == LinearGRAYColorspace) || |
139 | 0 | (image->colorspace == GRAYColorspace)) |
140 | 0 | image->type=GrayscaleType; |
141 | 0 | return(GetFirstImageInList(image)); |
142 | 0 | } |
143 | | |
144 | | /* |
145 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
146 | | % % |
147 | | % % |
148 | | % % |
149 | | % R e g i s t e r T I L E I m a g e % |
150 | | % % |
151 | | % % |
152 | | % % |
153 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
154 | | % |
155 | | % RegisterTILEImage() adds attributes for the TILE image format to |
156 | | % the list of supported formats. The attributes include the image format |
157 | | % tag, a method to read and/or write the format, whether the format |
158 | | % supports the saving of more than one frame to the same file or blob, |
159 | | % whether the format supports native in-memory I/O, and a brief |
160 | | % description of the format. |
161 | | % |
162 | | % The format of the RegisterTILEImage method is: |
163 | | % |
164 | | % size_t RegisterTILEImage(void) |
165 | | % |
166 | | */ |
167 | | ModuleExport size_t RegisterTILEImage(void) |
168 | 9 | { |
169 | 9 | MagickInfo |
170 | 9 | *entry; |
171 | | |
172 | 9 | entry=AcquireMagickInfo("TILE","TILE","Tile image with a texture"); |
173 | 9 | entry->decoder=(DecodeImageHandler *) ReadTILEImage; |
174 | 9 | entry->flags|=CoderRawSupportFlag; |
175 | 9 | entry->flags|=CoderEndianSupportFlag; |
176 | 9 | entry->format_type=ImplicitFormatType; |
177 | 9 | (void) RegisterMagickInfo(entry); |
178 | 9 | return(MagickImageCoderSignature); |
179 | 9 | } |
180 | | |
181 | | /* |
182 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
183 | | % % |
184 | | % % |
185 | | % % |
186 | | % U n r e g i s t e r T I L E I m a g e % |
187 | | % % |
188 | | % % |
189 | | % % |
190 | | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
191 | | % |
192 | | % UnregisterTILEImage() removes format registrations made by the |
193 | | % TILE module from the list of supported formats. |
194 | | % |
195 | | % The format of the UnregisterTILEImage method is: |
196 | | % |
197 | | % UnregisterTILEImage(void) |
198 | | % |
199 | | */ |
200 | | ModuleExport void UnregisterTILEImage(void) |
201 | 0 | { |
202 | 0 | (void) UnregisterMagickInfo("TILE"); |
203 | 0 | } |