cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 % |
cristy | de984cd | 2013-12-01 14:49:27 +0000 | [diff] [blame] | 16 | % Cristy % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 17 | % July 1992 % |
| 18 | % % |
| 19 | % % |
cristy | b56bb24 | 2014-11-25 17:12:48 +0000 | [diff] [blame] | 20 | % Copyright 1999-2015 ImageMagick Studio LLC, a non-profit organization % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | */ |
cristy | 4c08aed | 2011-07-01 19:47:50 +0000 | [diff] [blame] | 42 | #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" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 66 | |
| 67 | /* |
| 68 | Forward declarations. |
| 69 | */ |
| 70 | static MagickBooleanType |
cristy | 1e178e7 | 2011-08-28 19:44:34 +0000 | [diff] [blame] | 71 | WritePreviewImage(const ImageInfo *,Image *,ExceptionInfo *); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 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 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 93 | % size_t RegisterPREVIEWImage(void) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 94 | % |
| 95 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 96 | ModuleExport size_t RegisterPREVIEWImage(void) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 97 | { |
| 98 | MagickInfo |
| 99 | *entry; |
| 100 | |
dirk | 06b627a | 2015-04-06 18:59:17 +0000 | [diff] [blame] | 101 | entry=AcquireMagickInfo("PREVIEW","PREVIEW", |
| 102 | "Show a preview an image enhancement, effect, or f/x"); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 103 | entry->encoder=(EncodeImageHandler *) WritePreviewImage; |
dirk | 08e9a11 | 2015-02-22 01:51:41 +0000 | [diff] [blame] | 104 | entry->flags^=CoderAdjoinFlag; |
cristy | 009d739 | 2010-07-25 22:08:41 +0000 | [diff] [blame] | 105 | entry->format_type=ImplicitFormatType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 106 | (void) RegisterMagickInfo(entry); |
| 107 | return(MagickImageCoderSignature); |
| 108 | } |
| 109 | |
| 110 | /* |
| 111 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 112 | % % |
| 113 | % % |
| 114 | % % |
| 115 | % U n r e g i s t e r P R E V I E W I m a g e % |
| 116 | % % |
| 117 | % % |
| 118 | % % |
| 119 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 120 | % |
| 121 | % UnregisterPREVIEWImage() removes format registrations made by the |
| 122 | % PREVIEW module from the list of supported formats. |
| 123 | % |
| 124 | % The format of the UnregisterPREVIEWImage method is: |
| 125 | % |
| 126 | % UnregisterPREVIEWImage(void) |
| 127 | % |
| 128 | */ |
| 129 | ModuleExport void UnregisterPREVIEWImage(void) |
| 130 | { |
| 131 | (void) UnregisterMagickInfo("PREVIEW"); |
| 132 | } |
| 133 | |
| 134 | /* |
| 135 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 136 | % % |
| 137 | % % |
| 138 | % % |
| 139 | % W r i t e P R E V I E W I m a g e % |
| 140 | % % |
| 141 | % % |
| 142 | % % |
| 143 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 144 | % |
| 145 | % WritePreviewImage creates several tiles each with a varying |
| 146 | % stength of an image enhancement function (e.g. gamma). The image is written |
| 147 | % in the MIFF format. |
| 148 | % |
| 149 | % The format of the WritePreviewImage method is: |
| 150 | % |
| 151 | % MagickBooleanType WritePreviewImage(const ImageInfo *image_info, |
cristy | 1e178e7 | 2011-08-28 19:44:34 +0000 | [diff] [blame] | 152 | % Image *image,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 153 | % |
| 154 | % A description of each parameter follows. |
| 155 | % |
| 156 | % o image_info: the image info. |
| 157 | % |
| 158 | % o image: The image. |
| 159 | % |
cristy | 1e178e7 | 2011-08-28 19:44:34 +0000 | [diff] [blame] | 160 | % o exception: return any errors or warnings in this structure. |
| 161 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 162 | */ |
| 163 | static MagickBooleanType WritePreviewImage(const ImageInfo *image_info, |
cristy | 1e178e7 | 2011-08-28 19:44:34 +0000 | [diff] [blame] | 164 | Image *image,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 165 | { |
| 166 | Image |
| 167 | *preview_image; |
| 168 | |
| 169 | ImageInfo |
| 170 | *write_info; |
| 171 | |
| 172 | MagickBooleanType |
| 173 | status; |
| 174 | |
| 175 | /* |
| 176 | Open output image file. |
| 177 | */ |
| 178 | assert(image_info != (const ImageInfo *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 179 | assert(image_info->signature == MagickCoreSignature); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 180 | assert(image != (Image *) NULL); |
cristy | e1c94d9 | 2015-06-28 12:16:33 +0000 | [diff] [blame] | 181 | assert(image->signature == MagickCoreSignature); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 182 | if (image->debug != MagickFalse) |
| 183 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
cristy | 1e178e7 | 2011-08-28 19:44:34 +0000 | [diff] [blame] | 184 | preview_image=PreviewImage(image,image_info->preview_type,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 185 | if (preview_image == (Image *) NULL) |
| 186 | return(MagickFalse); |
| 187 | (void) CopyMagickString(preview_image->filename,image_info->filename, |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 188 | MagickPathExtent); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 189 | write_info=CloneImageInfo(image_info); |
cristy | 1e178e7 | 2011-08-28 19:44:34 +0000 | [diff] [blame] | 190 | (void) SetImageInfo(write_info,1,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 191 | if (LocaleCompare(write_info->magick,"PREVIEW") == 0) |
cristy | 151b66d | 2015-04-15 10:50:31 +0000 | [diff] [blame] | 192 | (void) FormatLocaleString(preview_image->filename,MagickPathExtent, |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 193 | "miff:%s",image_info->filename); |
cristy | 1e178e7 | 2011-08-28 19:44:34 +0000 | [diff] [blame] | 194 | status=WriteImage(write_info,preview_image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 195 | preview_image=DestroyImage(preview_image); |
| 196 | write_info=DestroyImageInfo(write_info); |
| 197 | return(status); |
| 198 | } |