summaryrefslogtreecommitdiff
path: root/coders/pes.c
diff options
context:
space:
mode:
authorcristy <urban-warrior@git.imagemagick.org>2010-01-24 17:14:03 +0000
committercristy <urban-warrior@git.imagemagick.org>2010-01-24 17:14:03 +0000
commit7adb4dba035b9c438a6fbe93867120b700f73acc (patch)
treebe4045ec873ecf00e429f835e9edf5cf5a413a03 /coders/pes.c
parent7527f1092408a37b151ba8b30f1b428ba4fd90e2 (diff)
downloadImageMagick-7adb4dba035b9c438a6fbe93867120b700f73acc.tar.gz
Diffstat (limited to 'coders/pes.c')
-rw-r--r--coders/pes.c219
1 files changed, 219 insertions, 0 deletions
diff --git a/coders/pes.c b/coders/pes.c
new file mode 100644
index 000000000..ce645d218
--- /dev/null
+++ b/coders/pes.c
@@ -0,0 +1,219 @@
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% PPPP EEEEE SSSSS %
+% P P E SS %
+% PPPP EEE SSS %
+% P E SS %
+% P EEEEE SSSSS %
+% %
+% %
+% Read/Write Brother PES Image Format %
+% %
+% Software Design %
+% John Cristy %
+% July 2009 %
+% %
+% %
+% Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
+% dedicated to making software imaging solutions freely available. %
+% %
+% You may not use this file except in compliance with the License. You may %
+% obtain a copy of the License at %
+% %
+% http://www.imagemagick.org/script/license.php %
+% %
+% Unless required by applicable law or agreed to in writing, software %
+% distributed under the License is distributed on an "AS IS" BASIS, %
+% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. %
+% See the License for the specific language governing permissions and %
+% limitations under the License. %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+%
+*/
+
+/*
+ Include declarations.
+*/
+#include "magick/studio.h"
+#include "magick/property.h"
+#include "magick/blob.h"
+#include "magick/blob-private.h"
+#include "magick/cache.h"
+#include "magick/client.h"
+#include "magick/colorspace.h"
+#include "magick/constitute.h"
+#include "magick/decorate.h"
+#include "magick/exception.h"
+#include "magick/exception-private.h"
+#include "magick/gem.h"
+#include "magick/geometry.h"
+#include "magick/image.h"
+#include "magick/image-private.h"
+#include "magick/list.h"
+#include "magick/magick.h"
+#include "magick/memory_.h"
+#include "magick/monitor.h"
+#include "magick/monitor-private.h"
+#include "magick/montage.h"
+#include "magick/resize.h"
+#include "magick/shear.h"
+#include "magick/quantum-private.h"
+#include "magick/static.h"
+#include "magick/string_.h"
+#include "magick/module.h"
+#include "magick/transform.h"
+#include "magick/utility.h"
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% I s P E S %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% IsPES() returns MagickTrue if the image format type, identified by the
+% magick string, is PES.
+%
+% The format of the IsPES method is:
+%
+% MagickBooleanType IsPES(const unsigned char *magick,const size_t length)
+%
+% A description of each parameter follows:
+%
+% o magick: compare image format pattern against these bytes.
+%
+% o length: Specifies the length of the magick string.
+%
+*/
+static MagickBooleanType IsPES(const unsigned char *magick,const size_t length)
+{
+ if (length < 4)
+ return(MagickFalse);
+ if (LocaleNCompare((const char *) magick,"#PES",4) == 0)
+ return(MagickTrue);
+ return(MagickFalse);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% R e a d P E S I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% ReadPESImage() reads a Brother PES image file and returns it. It allocates
+% the memory necessary for the new Image structure and returns a pointer to
+% the new image.
+%
+% The format of the ReadPESImage method is:
+%
+% image=ReadPESImage(image_info)
+%
+% A description of each parameter follows:
+%
+% o image_info: the image info.
+%
+% o exception: return any errors or warnings in this structure.
+%
+*/
+static Image *ReadPESImage(const ImageInfo *image_info,ExceptionInfo *exception)
+{
+ Image
+ *image;
+
+ MagickBooleanType
+ status;
+
+ /*
+ Open image file.
+ */
+ assert(image_info != (const ImageInfo *) NULL);
+ assert(image_info->signature == MagickSignature);
+ if (image_info->debug != MagickFalse)
+ (void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
+ image_info->filename);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ image=AcquireImage(image_info);
+ status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
+ if (status == MagickFalse)
+ {
+ image=DestroyImageList(image);
+ return((Image *) NULL);
+ }
+ return(GetFirstImageInList(image));
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% R e g i s t e r P E S I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% RegisterPESImage() adds attributes for the PES image format to
+% the list of supported formats. The attributes include the image format
+% tag, a method to read and/or write the format, whether the format
+% supports the saving of more than one frame to the same file or blob,
+% whether the format supports native in-memory I/O, and a brief
+% description of the format.
+%
+% The format of the RegisterPESImage method is:
+%
+% unsigned long RegisterPESImage(void)
+%
+*/
+ModuleExport unsigned long RegisterPESImage(void)
+{
+ MagickInfo
+ *entry;
+
+ entry=SetMagickInfo("PES");
+ entry->decoder=(DecodeImageHandler *) ReadPESImage;
+ entry->magick=(IsImageFormatHandler *) IsPES;
+ entry->adjoin=MagickFalse;
+ entry->description=ConstantString("Brother PES");
+ entry->module=ConstantString("PES");
+ return(MagickImageCoderSignature);
+}
+
+/*
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+% %
+% %
+% %
+% U n r e g i s t e r P E S I m a g e %
+% %
+% %
+% %
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% UnregisterPESImage() removes format registrations made by the
+% PES module from the list of supported formats.
+%
+% The format of the UnregisterPESImage method is:
+%
+% UnregisterPESImage(void)
+%
+*/
+ModuleExport void UnregisterPESImage(void)
+{
+ (void) UnregisterMagickInfo("PES");
+}