]> granicus.if.org Git - imagemagick/blob - coders/pes.c
(no commit message)
[imagemagick] / coders / pes.c
1 /*
2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %                                                                             %
4 %                                                                             %
5 %                                                                             %
6 %                            PPPP   EEEEE  SSSSS                              %
7 %                            P   P  E      SS                                 %
8 %                            PPPP   EEE     SSS                               %
9 %                            P      E         SS                              %
10 %                            P      EEEEE  SSSSS                              %
11 %                                                                             %
12 %                                                                             %
13 %                     Read/Write Brother PES Image Format                     %
14 %                                                                             %
15 %                              Software Design                                %
16 %                                John Cristy                                  %
17 %                                 July 2009                                   %
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 \f
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/cache.h"
47 #include "magick/client.h"
48 #include "magick/colorspace.h"
49 #include "magick/constitute.h"
50 #include "magick/decorate.h"
51 #include "magick/exception.h"
52 #include "magick/exception-private.h"
53 #include "magick/gem.h"
54 #include "magick/geometry.h"
55 #include "magick/image.h"
56 #include "magick/image-private.h"
57 #include "magick/list.h"
58 #include "magick/magick.h"
59 #include "magick/memory_.h"
60 #include "magick/monitor.h"
61 #include "magick/monitor-private.h"
62 #include "magick/montage.h"
63 #include "magick/resize.h"
64 #include "magick/shear.h"
65 #include "magick/quantum-private.h"
66 #include "magick/static.h"
67 #include "magick/string_.h"
68 #include "magick/module.h"
69 #include "magick/transform.h"
70 #include "magick/utility.h"
71 \f
72 /*
73 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
74 %                                                                             %
75 %                                                                             %
76 %                                                                             %
77 %   I s P E S                                                                 %
78 %                                                                             %
79 %                                                                             %
80 %                                                                             %
81 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
82 %
83 %  IsPES() returns MagickTrue if the image format type, identified by the
84 %  magick string, is PES.
85 %
86 %  The format of the IsPES method is:
87 %
88 %      MagickBooleanType IsPES(const unsigned char *magick,const size_t length)
89 %
90 %  A description of each parameter follows:
91 %
92 %    o magick: compare image format pattern against these bytes.
93 %
94 %    o length: Specifies the length of the magick string.
95 %
96 */
97 static MagickBooleanType IsPES(const unsigned char *magick,const size_t length)
98 {
99   if (length < 4)
100     return(MagickFalse);
101   if (LocaleNCompare((const char *) magick,"#PES",4) == 0)
102     return(MagickTrue);
103   return(MagickFalse);
104 }
105 \f
106 /*
107 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
108 %                                                                             %
109 %                                                                             %
110 %                                                                             %
111 %   R e a d P E S I m a g e                                                   %
112 %                                                                             %
113 %                                                                             %
114 %                                                                             %
115 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
116 %
117 %  ReadPESImage() reads a Brother PES image file and returns it.  It allocates
118 %  the memory necessary for the new Image structure and returns a pointer to
119 %  the new image.
120 %
121 %  The format of the ReadPESImage method is:
122 %
123 %      image=ReadPESImage(image_info)
124 %
125 %  A description of each parameter follows:
126 %
127 %    o image_info: the image info.
128 %
129 %    o exception: return any errors or warnings in this structure.
130 %
131 */
132 static Image *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception)
133 {
134   Image
135     *image;
136
137   MagickBooleanType
138     status;
139
140   /*
141     Open image file.
142   */
143   assert(image_info != (const ImageInfo *) NULL);
144   assert(image_info->signature == MagickSignature);
145   if (image_info->debug != MagickFalse)
146     (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
147       image_info->filename);
148   assert(exception != (ExceptionInfo *) NULL);
149   assert(exception->signature == MagickSignature);
150   image=AcquireImage(image_info);
151   status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
152   if (status == MagickFalse)
153     {
154       image=DestroyImageList(image);
155       return((Image *) NULL);
156     }
157   return(GetFirstImageInList(image));
158 }
159 \f
160 /*
161 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
162 %                                                                             %
163 %                                                                             %
164 %                                                                             %
165 %   R e g i s t e r P E S I m a g e                                           %
166 %                                                                             %
167 %                                                                             %
168 %                                                                             %
169 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
170 %
171 %  RegisterPESImage() adds attributes for the PES image format to
172 %  the list of supported formats.  The attributes include the image format
173 %  tag, a method to read and/or write the format, whether the format
174 %  supports the saving of more than one frame to the same file or blob,
175 %  whether the format supports native in-memory I/O, and a brief
176 %  description of the format.
177 %
178 %  The format of the RegisterPESImage method is:
179 %
180 %      unsigned long RegisterPESImage(void)
181 %
182 */
183 ModuleExport unsigned long RegisterPESImage(void)
184 {
185   MagickInfo
186     *entry;
187
188   entry=SetMagickInfo("PES");
189   entry->decoder=(DecodeImageHandler *) ReadPESImage;
190   entry->magick=(IsImageFormatHandler *) IsPES;
191   entry->adjoin=MagickFalse;
192   entry->description=ConstantString("Brother PES");
193   entry->module=ConstantString("PES");
194   return(MagickImageCoderSignature);
195 }
196 \f
197 /*
198 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
199 %                                                                             %
200 %                                                                             %
201 %                                                                             %
202 %   U n r e g i s t e r P E S I m a g e                                       %
203 %                                                                             %
204 %                                                                             %
205 %                                                                             %
206 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
207 %
208 %  UnregisterPESImage() removes format registrations made by the
209 %  PES module from the list of supported formats.
210 %
211 %  The format of the UnregisterPESImage method is:
212 %
213 %      UnregisterPESImage(void)
214 %
215 */
216 ModuleExport void UnregisterPESImage(void)
217 {
218   (void) UnregisterMagickInfo("PES");
219 }