% July 1992 %
% %
% %
-% Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2018 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 %
+% https://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, %
#include "MagickCore/colormap.h"
#include "MagickCore/colorspace.h"
#include "MagickCore/colorspace-private.h"
+#include "MagickCore/constitute.h"
#include "MagickCore/exception.h"
#include "MagickCore/exception-private.h"
#include "MagickCore/compress.h"
#include "MagickCore/monitor.h"
#include "MagickCore/monitor-private.h"
#include "MagickCore/quantum-private.h"
+#include "MagickCore/resource_.h"
#include "MagickCore/static.h"
#include "MagickCore/string_.h"
#include "MagickCore/module.h"
% o exception: return any errors or warnings in this structure.
%
*/
+static Image* FaxReadG3(Image *image,ExceptionInfo *exception)
+{
+ MagickBooleanType
+ status;
+
+ status=HuffmanDecodeImage(image,exception);
+ if (status == MagickFalse)
+ ThrowFileException(exception,CorruptImageError,"UnableToReadImageData",
+ image->filename);
+ if (EOFBlob(image) != MagickFalse)
+ ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+ image->filename);
+ (void) CloseBlob(image);
+ return(GetFirstImageInList(image));
+}
+
+static Image* FaxReadG4(Image *image,const ImageInfo *image_info,
+ ExceptionInfo *exception)
+{
+ char
+ filename[MagickPathExtent];
+
+ ImageInfo
+ *read_info;
+
+ filename[0]='\0';
+ if (ImageToFile(image,filename,exception) == MagickFalse)
+ ThrowImageException(FileOpenError,"UnableToCreateTemporaryFile");
+ (void) CloseBlob(image);
+ image=DestroyImage(image);
+ read_info=CloneImageInfo(image_info);
+ SetImageInfoBlob(read_info,(void *) NULL,0);
+ (void) FormatLocaleString(read_info->filename,MagickPathExtent,"group4:%s",
+ filename);
+ read_info->orientation=TopLeftOrientation;
+ image=ReadImage(read_info,exception);
+ if (image != (Image *) NULL)
+ {
+ (void) CopyMagickString(image->filename,image_info->filename,
+ MagickPathExtent);
+ (void) CopyMagickString(image->magick_filename,image_info->filename,
+ MagickPathExtent);
+ (void) CopyMagickString(image->magick,"G4",MagickPathExtent);
+ }
+ read_info=DestroyImageInfo(read_info);
+ (void) RelinquishUniqueFileResource(filename);
+ return(GetFirstImageInList(image));
+}
+
static Image *ReadFAXImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
Image
Open image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
if (image_info->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
(void) CloseBlob(image);
return(GetFirstImageInList(image));
}
- status=HuffmanDecodeImage(image,exception);
+ status=SetImageExtent(image,image->columns,image->rows,exception);
if (status == MagickFalse)
- ThrowReaderException(CorruptImageError,"UnableToReadImageData");
- if (EOFBlob(image) != MagickFalse)
- ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
- image->filename);
- (void) CloseBlob(image);
- return(GetFirstImageInList(image));
+ return(DestroyImageList(image));
+ if (LocaleCompare(image_info->magick,"G4") == 0)
+ return(FaxReadG4(image,image_info,exception));
+ else
+ return(FaxReadG3(image,exception));
}
\f
/*
"resized using a geometry of \"150x100%\".\n"
};
- entry=SetMagickInfo("FAX");
+ entry=AcquireMagickInfo("FAX","FAX","Group 3 FAX");
entry->decoder=(DecodeImageHandler *) ReadFAXImage;
entry->encoder=(EncodeImageHandler *) WriteFAXImage;
entry->magick=(IsImageFormatHandler *) IsFAX;
- entry->description=ConstantString("Group 3 FAX");
entry->note=ConstantString(Note);
- entry->module=ConstantString("FAX");
(void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("G3");
+ entry=AcquireMagickInfo("FAX","G3","Group 3 FAX");
+ entry->decoder=(DecodeImageHandler *) ReadFAXImage;
+ entry->encoder=(EncodeImageHandler *) WriteFAXImage;
+ entry->magick=(IsImageFormatHandler *) IsFAX;
+ entry->flags^=CoderAdjoinFlag;
+ (void) RegisterMagickInfo(entry);
+ entry=AcquireMagickInfo("FAX","G4","Group 4 FAX");
entry->decoder=(DecodeImageHandler *) ReadFAXImage;
entry->encoder=(EncodeImageHandler *) WriteFAXImage;
entry->magick=(IsImageFormatHandler *) IsFAX;
- entry->adjoin=MagickFalse;
- entry->description=ConstantString("Group 3 FAX");
- entry->module=ConstantString("FAX");
+ entry->flags^=CoderAdjoinFlag;
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
{
(void) UnregisterMagickInfo("FAX");
(void) UnregisterMagickInfo("G3");
+ (void) UnregisterMagickInfo("G4");
}
\f
/*
Open output image file.
*/
assert(image_info != (const ImageInfo *) NULL);
- assert(image_info->signature == MagickSignature);
+ assert(image_info->signature == MagickCoreSignature);
assert(image != (Image *) NULL);
- assert(image->signature == MagickSignature);
+ assert(image->signature == MagickCoreSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(exception != (ExceptionInfo *) NULL);
- assert(exception->signature == MagickSignature);
+ assert(exception->signature == MagickCoreSignature);
status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
write_info=CloneImageInfo(image_info);
- (void) CopyMagickString(write_info->magick,"FAX",MaxTextExtent);
+ (void) CopyMagickString(write_info->magick,"FAX",MagickPathExtent);
scene=0;
do
{
/*
Convert MIFF to monochrome.
*/
- if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
- (void) TransformImageColorspace(image,sRGBColorspace,exception);
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
status=HuffmanEncodeImage(write_info,image,image,exception);
if (GetNextImageInList(image) == (Image *) NULL)
break;