blob: 224a171bdc2637eb677eb1ee05836e728d209c06 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
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% John Cristy %
17% July 1992 %
18% %
19% %
cristy1454be72011-12-19 01:52:48 +000020% Copyright 1999-2012 ImageMagick Studio LLC, a non-profit organization %
cristy3ed852e2009-09-05 21:47:34 +000021% 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% http://www.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*/
cristy4c08aed2011-07-01 19:47:50 +000042#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"
cristy3ed852e2009-09-05 21:47:34 +000059
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%
cristyfcb1a662009-09-20 02:31:52 +000077% Image *ReadTILEImage(const ImageInfo *image_info,
78% ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +000079%
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*/
87static Image *ReadTILEImage(const ImageInfo *image_info,
88 ExceptionInfo *exception)
89{
90 Image
91 *image,
92 *tile_image;
93
94 ImageInfo
95 *read_info;
96
97 /*
98 Initialize Image structure.
99 */
100 assert(image_info != (const ImageInfo *) NULL);
101 assert(image_info->signature == MagickSignature);
102 if (image_info->debug != MagickFalse)
103 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
104 image_info->filename);
105 assert(exception != (ExceptionInfo *) NULL);
106 assert(exception->signature == MagickSignature);
107 read_info=CloneImageInfo(image_info);
108 SetImageInfoBlob(read_info,(void *) NULL,0);
109 *read_info->magick='\0';
110 tile_image=ReadImage(read_info,exception);
111 read_info=DestroyImageInfo(read_info);
112 if (tile_image == (Image *) NULL)
113 return((Image *) NULL);
cristy9950d572011-10-01 18:22:35 +0000114 image=AcquireImage(image_info,exception);
cristy3ed852e2009-09-05 21:47:34 +0000115 if ((image->columns == 0) || (image->rows == 0))
116 ThrowReaderException(OptionError,"MustSpecifyImageSize");
117 if (*image_info->filename == '\0')
118 ThrowReaderException(OptionError,"MustSpecifyAnImageName");
cristy188f29a2012-06-24 19:09:53 +0000119 image->colorspace=tile_image->colorspace;
cristy3ed852e2009-09-05 21:47:34 +0000120 image->matte=tile_image->matte;
121 if (image->matte != MagickFalse)
cristyea1a8aa2011-10-20 13:24:06 +0000122 (void) SetImageBackgroundColor(image,exception);
cristy3ed852e2009-09-05 21:47:34 +0000123 (void) CopyMagickString(image->filename,image_info->filename,MaxTextExtent);
124 if (LocaleCompare(tile_image->magick,"PATTERN") == 0)
125 {
126 tile_image->tile_offset.x=0;
127 tile_image->tile_offset.y=0;
128 }
cristye941a752011-10-15 01:52:48 +0000129 (void) TextureImage(image,tile_image,exception);
cristy3ed852e2009-09-05 21:47:34 +0000130 tile_image=DestroyImage(tile_image);
cristy188f29a2012-06-24 19:09:53 +0000131 if (image->colorspace == GRAYColorspace)
132 image->type=GrayscaleType;
cristy3ed852e2009-09-05 21:47:34 +0000133 return(GetFirstImageInList(image));
134}
135
136/*
137%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138% %
139% %
140% %
141% R e g i s t e r T I L E I m a g e %
142% %
143% %
144% %
145%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146%
147% RegisterTILEImage() adds attributes for the TILE image format to
148% the list of supported formats. The attributes include the image format
149% tag, a method to read and/or write the format, whether the format
150% supports the saving of more than one frame to the same file or blob,
151% whether the format supports native in-memory I/O, and a brief
152% description of the format.
153%
154% The format of the RegisterTILEImage method is:
155%
cristybb503372010-05-27 20:51:26 +0000156% size_t RegisterTILEImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000157%
158*/
cristybb503372010-05-27 20:51:26 +0000159ModuleExport size_t RegisterTILEImage(void)
cristy3ed852e2009-09-05 21:47:34 +0000160{
161 MagickInfo
162 *entry;
163
164 entry=SetMagickInfo("TILE");
165 entry->decoder=(DecodeImageHandler *) ReadTILEImage;
166 entry->raw=MagickTrue;
167 entry->endian_support=MagickTrue;
cristy009d7392010-07-25 22:08:41 +0000168 entry->format_type=ImplicitFormatType;
cristy3ed852e2009-09-05 21:47:34 +0000169 entry->description=ConstantString("Tile image with a texture");
170 entry->module=ConstantString("TILE");
171 (void) RegisterMagickInfo(entry);
172 return(MagickImageCoderSignature);
173}
174
175/*
176%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
177% %
178% %
179% %
180% U n r e g i s t e r T I L E I m a g e %
181% %
182% %
183% %
184%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
185%
186% UnregisterTILEImage() removes format registrations made by the
187% TILE module from the list of supported formats.
188%
189% The format of the UnregisterTILEImage method is:
190%
191% UnregisterTILEImage(void)
192%
193*/
194ModuleExport void UnregisterTILEImage(void)
195{
196 (void) UnregisterMagickInfo("TILE");
197}