root / ImageMagick / trunk / coders / preview.c

Revision 11742, 8.4 kB (checked in by cristy, 2 months ago)
Line 
1/*
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%                                                                             %
20%  Copyright 1999-2008 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%    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*/
42#include "magick/studio.h"
43#include "magick/property.h"
44#include "magick/blob.h"
45#include "magick/blob-private.h"
46#include "magick/client.h"
47#include "magick/constitute.h"
48#include "magick/effect.h"
49#include "magick/exception.h"
50#include "magick/exception-private.h"
51#include "magick/image.h"
52#include "magick/image-private.h"
53#include "magick/list.h"
54#include "magick/magick.h"
55#include "magick/memory_.h"
56#include "magick/monitor.h"
57#include "magick/monitor-private.h"
58#include "magick/resize.h"
59#include "magick/resource_.h"
60#include "magick/quantum-private.h"
61#include "magick/static.h"
62#include "magick/string_.h"
63#include "magick/module.h"
64#include "magick/transform.h"
65#include "magick/utility.h"
66
67/*
68  Forward declarations.
69*/
70static MagickBooleanType
71  WritePreviewImage(const ImageInfo *,Image *);
72
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%
93%      unsigned long RegisterPREVIEWImage(void)
94%
95*/
96ModuleExport unsigned long RegisterPREVIEWImage(void)
97{
98  MagickInfo
99    *entry;
100
101  entry=SetMagickInfo("PREVIEW");
102  entry->encoder=(EncodeImageHandler *) WritePreviewImage;
103  entry->adjoin=MagickFalse;
104  entry->format_type=ImplicitFormatType;
105  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,
154%        Image *image)
155%
156%  A description of each parameter follows.
157%
158%    o image_info: the image info.
159%
160%    o image:  The image.
161%
162%
163*/
164static MagickBooleanType WritePreviewImage(const ImageInfo *image_info,
165  Image *image)
166{
167  Image
168    *preview_image;
169
170  ImageInfo
171    *write_info;
172
173  MagickBooleanType
174    status;
175
176  /*
177    Open output image file.
178  */
179  assert(image_info != (const ImageInfo *) NULL);
180  assert(image_info->signature == MagickSignature);
181  assert(image != (Image *) NULL);
182  assert(image->signature == MagickSignature);
183  if (image->debug != MagickFalse)
184    (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
185  preview_image=PreviewImage(image,image_info->preview_type,&image->exception);
186  if (preview_image == (Image *) NULL)
187    return(MagickFalse);
188  (void) CopyMagickString(preview_image->filename,image_info->filename,
189    MaxTextExtent);
190  write_info=CloneImageInfo(image_info);
191  (void) SetImageInfo(write_info,MagickTrue,&image->exception);
192  if (LocaleCompare(write_info->magick,"PREVIEW") == 0)
193    (void) FormatMagickString(preview_image->filename,MaxTextExtent,
194      "miff:%s",image_info->filename);
195  status=WriteImage(write_info,preview_image);
196  preview_image=DestroyImage(preview_image);
197  write_info=DestroyImageInfo(write_info);
198  return(status);
199}
Note: See TracBrowser for help on using the browser.