/branches/ImageMagick-6.6.2/coders/mpr.c

https://github.com/trevor/ImageMagick · C · 220 lines · 79 code · 3 blank · 138 comment · 14 complexity · 30d8ce415a237c1974d6431c8097a4bf MD5 · raw file

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