blob: 35746f330a26c744ff2fc6aab91a49475e0929b6 [file] [log] [blame]
cristy3ed852e2009-09-05 21:47:34 +00001/*
2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3% %
4% %
5% %
6% PPPP RRRR EEEEE V V IIIII EEEEE W W %
7% P P R R E V V I E W W %
8% PPPP RRRR EEE V V I EEE W W %
9% P R R E V V I E W W W %
10% P R R EEEEE V IIIII EEEEE W W %
11% %
12% %
13% Write A Preview Image. %
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/property.h"
44#include "MagickCore/blob.h"
45#include "MagickCore/blob-private.h"
46#include "MagickCore/client.h"
47#include "MagickCore/constitute.h"
48#include "MagickCore/effect.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/monitor.h"
57#include "MagickCore/monitor-private.h"
58#include "MagickCore/resize.h"
59#include "MagickCore/resource_.h"
60#include "MagickCore/quantum-private.h"
61#include "MagickCore/static.h"
62#include "MagickCore/string_.h"
63#include "MagickCore/module.h"
64#include "MagickCore/transform.h"
65#include "MagickCore/utility.h"
cristy3ed852e2009-09-05 21:47:34 +000066
67/*
68 Forward declarations.
69*/
70static MagickBooleanType
cristy1e178e72011-08-28 19:44:34 +000071 WritePreviewImage(const ImageInfo *,Image *,ExceptionInfo *);
cristy3ed852e2009-09-05 21:47:34 +000072
73/*
74%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
75% %
76% %
77% %
78% R e g i s t e r P R E V I E W I m a g e %
79% %
80% %
81% %
82%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
83%
84% RegisterPREVIEWImage() adds attributes for the Preview image format to
85% the list of supported formats. The attributes include the image format
86% tag, a method to read and/or write the format, whether the format
87% supports the saving of more than one frame to the same file or blob,
88% whether the format supports native in-memory I/O, and a brief
89% description of the format.
90%
91% The format of the RegisterPREVIEWImage method is:
92%
cristybb503372010-05-27 20:51:26 +000093% size_t RegisterPREVIEWImage(void)
cristy3ed852e2009-09-05 21:47:34 +000094%
95*/
cristybb503372010-05-27 20:51:26 +000096ModuleExport size_t RegisterPREVIEWImage(void)
cristy3ed852e2009-09-05 21:47:34 +000097{
98 MagickInfo
99 *entry;
100
101 entry=SetMagickInfo("PREVIEW");
102 entry->encoder=(EncodeImageHandler *) WritePreviewImage;
103 entry->adjoin=MagickFalse;
cristy009d7392010-07-25 22:08:41 +0000104 entry->format_type=ImplicitFormatType;
cristy3ed852e2009-09-05 21:47:34 +0000105 entry->description=ConstantString(
106 "Show a preview an image enhancement, effect, or f/x");
107 entry->module=ConstantString("PREVIEW");
108 (void) RegisterMagickInfo(entry);
109 return(MagickImageCoderSignature);
110}
111
112/*
113%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
114% %
115% %
116% %
117% U n r e g i s t e r P R E V I E W I m a g e %
118% %
119% %
120% %
121%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
122%
123% UnregisterPREVIEWImage() removes format registrations made by the
124% PREVIEW module from the list of supported formats.
125%
126% The format of the UnregisterPREVIEWImage method is:
127%
128% UnregisterPREVIEWImage(void)
129%
130*/
131ModuleExport void UnregisterPREVIEWImage(void)
132{
133 (void) UnregisterMagickInfo("PREVIEW");
134}
135
136/*
137%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
138% %
139% %
140% %
141% W r i t e P R E V I E W I m a g e %
142% %
143% %
144% %
145%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
146%
147% WritePreviewImage creates several tiles each with a varying
148% stength of an image enhancement function (e.g. gamma). The image is written
149% in the MIFF format.
150%
151% The format of the WritePreviewImage method is:
152%
153% MagickBooleanType WritePreviewImage(const ImageInfo *image_info,
cristy1e178e72011-08-28 19:44:34 +0000154% Image *image,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000155%
156% A description of each parameter follows.
157%
158% o image_info: the image info.
159%
160% o image: The image.
161%
cristy1e178e72011-08-28 19:44:34 +0000162% o exception: return any errors or warnings in this structure.
163%
cristy3ed852e2009-09-05 21:47:34 +0000164*/
165static MagickBooleanType WritePreviewImage(const ImageInfo *image_info,
cristy1e178e72011-08-28 19:44:34 +0000166 Image *image,ExceptionInfo *exception)
cristy3ed852e2009-09-05 21:47:34 +0000167{
168 Image
169 *preview_image;
170
171 ImageInfo
172 *write_info;
173
174 MagickBooleanType
175 status;
176
177 /*
178 Open output image file.
179 */
180 assert(image_info != (const ImageInfo *) NULL);
181 assert(image_info->signature == MagickSignature);
182 assert(image != (Image *) NULL);
183 assert(image->signature == MagickSignature);
184 if (image->debug != MagickFalse)
185 (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
cristy1e178e72011-08-28 19:44:34 +0000186 preview_image=PreviewImage(image,image_info->preview_type,exception);
cristy3ed852e2009-09-05 21:47:34 +0000187 if (preview_image == (Image *) NULL)
188 return(MagickFalse);
189 (void) CopyMagickString(preview_image->filename,image_info->filename,
190 MaxTextExtent);
191 write_info=CloneImageInfo(image_info);
cristy1e178e72011-08-28 19:44:34 +0000192 (void) SetImageInfo(write_info,1,exception);
cristy3ed852e2009-09-05 21:47:34 +0000193 if (LocaleCompare(write_info->magick,"PREVIEW") == 0)
cristyb51dff52011-05-19 16:55:47 +0000194 (void) FormatLocaleString(preview_image->filename,MaxTextExtent,
cristy3ed852e2009-09-05 21:47:34 +0000195 "miff:%s",image_info->filename);
cristy1e178e72011-08-28 19:44:34 +0000196 status=WriteImage(write_info,preview_image,exception);
cristy3ed852e2009-09-05 21:47:34 +0000197 preview_image=DestroyImage(preview_image);
198 write_info=DestroyImageInfo(write_info);
199 return(status);
200}