cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 1 | /* |
| 2 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 3 | % % |
| 4 | % % |
| 5 | % % |
| 6 | % M M PPPP RRRR % |
| 7 | % MM MM P P R R % |
| 8 | % M M M PPPP RRRR % |
| 9 | % M M P R R % |
| 10 | % M M P R R % |
| 11 | % % |
| 12 | % % |
| 13 | % Read/Write the Magick Persistent Registry. % |
| 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 | fe676ee | 2013-11-18 13:03:38 +0000 | [diff] [blame] | 20 | % Copyright 1999-2014 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/blob.h" |
| 44 | #include "MagickCore/blob-private.h" |
| 45 | #include "MagickCore/exception.h" |
| 46 | #include "MagickCore/exception-private.h" |
| 47 | #include "MagickCore/magick.h" |
| 48 | #include "MagickCore/memory_.h" |
| 49 | #include "MagickCore/registry.h" |
| 50 | #include "MagickCore/quantum-private.h" |
| 51 | #include "MagickCore/static.h" |
| 52 | #include "MagickCore/string_.h" |
| 53 | #include "MagickCore/module.h" |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 54 | |
| 55 | /* |
| 56 | Forward declarations. |
| 57 | */ |
| 58 | static MagickBooleanType |
cristy | 1e178e7 | 2011-08-28 19:44:34 +0000 | [diff] [blame] | 59 | WriteMPRImage(const ImageInfo *,Image *,ExceptionInfo *); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 60 | |
| 61 | /* |
| 62 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 63 | % % |
| 64 | % % |
| 65 | % % |
| 66 | % R e a d M P R I m a g e % |
| 67 | % % |
| 68 | % % |
| 69 | % % |
| 70 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 71 | % |
| 72 | % ReadMPRImage() reads a Magick Persistent Registry image as a blob from |
| 73 | % memory. It allocates the memory necessary for the new Image structure and |
| 74 | % returns a pointer to the new image. |
| 75 | % |
| 76 | % The format of the ReadMPRImage method is: |
| 77 | % |
| 78 | % Image *ReadMPRImage(const ImageInfo *image_info, |
| 79 | % ExceptionInfo *exception) |
| 80 | % |
| 81 | % A description of each parameter follows: |
| 82 | % |
| 83 | % o image_info: the image info. |
| 84 | % |
| 85 | % o exception: return any errors or warnings in this structure. |
| 86 | % |
| 87 | */ |
| 88 | static Image *ReadMPRImage(const ImageInfo *image_info,ExceptionInfo *exception) |
| 89 | { |
| 90 | Image |
| 91 | *image; |
| 92 | |
| 93 | assert(image_info != (const ImageInfo *) NULL); |
| 94 | assert(image_info->signature == MagickSignature); |
| 95 | if (image_info->debug != MagickFalse) |
| 96 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s", |
| 97 | image_info->filename); |
| 98 | assert(exception != (ExceptionInfo *) NULL); |
| 99 | assert(exception->signature == MagickSignature); |
| 100 | image=(Image *) GetImageRegistry(ImageRegistryType,image_info->filename, |
| 101 | exception); |
cristy | d89d5aa | 2009-11-21 02:37:05 +0000 | [diff] [blame] | 102 | if (image != (Image *) NULL) |
cristy | 6fccee1 | 2011-10-20 18:43:18 +0000 | [diff] [blame] | 103 | (void) SyncImageSettings(image_info,image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 104 | return(image); |
| 105 | } |
| 106 | |
| 107 | /* |
| 108 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 109 | % % |
| 110 | % % |
| 111 | % % |
| 112 | % R e g i s t e r M P R I m a g e % |
| 113 | % % |
| 114 | % % |
| 115 | % % |
| 116 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 117 | % |
| 118 | % RegisterMPRImage() adds attributes for the MPR image format to |
| 119 | % the list of supported formats. The attributes include the image format |
| 120 | % tag, a method to read and/or write the format, whether the format |
| 121 | % supports the saving of more than one frame to the same file or blob, |
| 122 | % whether the format supports native in-memory I/O, and a brief |
| 123 | % description of the format. |
| 124 | % |
| 125 | % The format of the RegisterMPRImage method is: |
| 126 | % |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 127 | % size_t RegisterMPRImage(void) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 128 | % |
| 129 | */ |
cristy | bb50337 | 2010-05-27 20:51:26 +0000 | [diff] [blame] | 130 | ModuleExport size_t RegisterMPRImage(void) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 131 | { |
| 132 | MagickInfo |
| 133 | *entry; |
| 134 | |
| 135 | entry=SetMagickInfo("MPR"); |
| 136 | entry->decoder=(DecodeImageHandler *) ReadMPRImage; |
| 137 | entry->encoder=(EncodeImageHandler *) WriteMPRImage; |
| 138 | entry->adjoin=MagickFalse; |
cristy | 009d739 | 2010-07-25 22:08:41 +0000 | [diff] [blame] | 139 | entry->format_type=ImplicitFormatType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 140 | entry->stealth=MagickTrue; |
| 141 | entry->description=ConstantString("Magick Persistent Registry"); |
| 142 | entry->module=ConstantString("MPR"); |
| 143 | (void) RegisterMagickInfo(entry); |
| 144 | entry=SetMagickInfo("MPRI"); |
| 145 | entry->decoder=(DecodeImageHandler *) ReadMPRImage; |
| 146 | entry->encoder=(EncodeImageHandler *) WriteMPRImage; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 147 | entry->adjoin=MagickFalse; |
cristy | 009d739 | 2010-07-25 22:08:41 +0000 | [diff] [blame] | 148 | entry->format_type=ImplicitFormatType; |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 149 | entry->stealth=MagickTrue; |
| 150 | entry->description=ConstantString("Magick Persistent Registry"); |
| 151 | entry->module=ConstantString("MPRI"); |
| 152 | (void) RegisterMagickInfo(entry); |
| 153 | return(MagickImageCoderSignature); |
| 154 | } |
| 155 | |
| 156 | /* |
| 157 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 158 | % % |
| 159 | % % |
| 160 | % % |
| 161 | % U n r e g i s t e r M P R I m a g e % |
| 162 | % % |
| 163 | % % |
| 164 | % % |
| 165 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 166 | % |
| 167 | % UnregisterMPRImage() removes format registrations made by the |
| 168 | % MPR module from the list of supported formats. |
| 169 | % |
| 170 | % The format of the UnregisterMPRImage method is: |
| 171 | % |
| 172 | % UnregisterMPRImage(void) |
| 173 | % |
| 174 | */ |
| 175 | ModuleExport void UnregisterMPRImage(void) |
| 176 | { |
| 177 | (void) UnregisterMagickInfo("MPRI"); |
| 178 | (void) UnregisterMagickInfo("MPR"); |
| 179 | } |
| 180 | |
| 181 | /* |
| 182 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 183 | % % |
| 184 | % % |
| 185 | % % |
| 186 | % W r i t e M P R I m a g e % |
| 187 | % % |
| 188 | % % |
| 189 | % % |
| 190 | %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 191 | % |
| 192 | % WriteMPRImage() writes an image into the Magick Persistent Registry |
| 193 | % image as a blob from memory. It allocates the memory necessary for the |
| 194 | % new Image structure and returns a pointer to the new image. |
| 195 | % |
| 196 | % The format of the WriteMPRImage method is: |
| 197 | % |
cristy | 1e178e7 | 2011-08-28 19:44:34 +0000 | [diff] [blame] | 198 | % MagickBooleanType WriteMPRImage(const ImageInfo *image_info, |
| 199 | % Image *image,ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 200 | % |
| 201 | % A description of each parameter follows. |
| 202 | % |
| 203 | % o image_info: the image info. |
| 204 | % |
| 205 | % o image: The image. |
| 206 | % |
cristy | 1e178e7 | 2011-08-28 19:44:34 +0000 | [diff] [blame] | 207 | % o exception: return any errors or warnings in this structure. |
| 208 | % |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 209 | */ |
cristy | 1e178e7 | 2011-08-28 19:44:34 +0000 | [diff] [blame] | 210 | static MagickBooleanType WriteMPRImage(const ImageInfo *image_info,Image *image, |
| 211 | ExceptionInfo *exception) |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 212 | { |
| 213 | MagickBooleanType |
| 214 | status; |
| 215 | |
| 216 | assert(image_info != (const ImageInfo *) NULL); |
| 217 | assert(image_info->signature == MagickSignature); |
| 218 | assert(image != (Image *) NULL); |
| 219 | assert(image->signature == MagickSignature); |
cristy | c18ea1f | 2014-01-24 17:48:30 +0000 | [diff] [blame^] | 220 | magick_unreferenced(image_info); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 221 | if (image->debug != MagickFalse) |
| 222 | (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename); |
cristy | 1e178e7 | 2011-08-28 19:44:34 +0000 | [diff] [blame] | 223 | status=SetImageRegistry(ImageRegistryType,image->filename,image,exception); |
cristy | 3ed852e | 2009-09-05 21:47:34 +0000 | [diff] [blame] | 224 | return(status); |
| 225 | } |