% MagickCore Image Compression/Decompression Methods %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% May 1993 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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 %
Include declarations.
*/
#include "MagickCore/studio.h"
+#include "MagickCore/attribute.h"
#include "MagickCore/blob.h"
#include "MagickCore/blob-private.h"
#include "MagickCore/color-private.h"
#include "MagickCore/pixel-accessor.h"
#include "MagickCore/resource_.h"
#include "MagickCore/string_.h"
-#if defined(MAGICKCORE_TIFF_DELEGATE)
-#if defined(MAGICKCORE_HAVE_TIFFCONF_H)
-#include "tiffconf.h"
-#endif
-#include "tiffio.h"
-#define CCITTParam "-1"
-#else
-#define CCITTParam "0"
-#endif
#if defined(MAGICKCORE_ZLIB_DELEGATE)
#include "zlib.h"
#endif
%
% The format of the HuffmanDecodeImage method is:
%
-% MagickBooleanType HuffmanDecodeImage(Image *image)
+% MagickBooleanType HuffmanDecodeImage(Image *image,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image: the image.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static inline size_t MagickMax(const size_t x,const size_t y)
return(y);
}
-MagickExport MagickBooleanType HuffmanDecodeImage(Image *image)
+MagickExport MagickBooleanType HuffmanDecodeImage(Image *image,
+ ExceptionInfo *exception)
{
#define HashSize 1021
#define MBHashA 293
const HuffmanTable
*entry;
- ExceptionInfo
- *exception;
-
HuffmanTable
**mb_hash,
**mw_hash;
while (runlength < 11)
InputBit(bit);
do { InputBit(bit); } while ((int) bit == 0);
- image->x_resolution=204.0;
- image->y_resolution=196.0;
+ image->resolution.x=204.0;
+ image->resolution.y=196.0;
image->units=PixelsPerInchResolution;
- exception=(&image->exception);
- image_view=AcquireCacheView(image);
+ image_view=AcquireAuthenticCacheView(image,exception);
for (y=0; ((y < (ssize_t) image->rows) && (null_lines < 3)); )
{
register Quantum
*/
p=scanline;
q=QueueCacheViewAuthenticPixels(image_view,0,y,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
index=(Quantum) (*p++);
SetPixelIndex(image,index,q);
- SetPixelPacket(image,image->colormap+(ssize_t) index,q);
+ SetPixelInfoPixel(image,image->colormap+(ssize_t) index,q);
q+=GetPixelChannels(image);
}
if (SyncCacheViewAuthenticPixels(image_view,exception) == MagickFalse)
% The format of the HuffmanEncodeImage method is:
%
% MagickBooleanType HuffmanEncodeImage(const ImageInfo *image_info,
-% Image *image,Image *inject_image)
+% Image *image,Image *inject_image,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o inject_image: inject into the image stream.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType HuffmanEncodeImage(const ImageInfo *image_info,
- Image *image,Image *inject_image)
+ Image *image,Image *inject_image,ExceptionInfo *exception)
{
#define HuffmanOutputCode(entry) \
{ \
#define OutputBit(count) \
{ \
+DisableMSCWarning(4127) \
if (count > 0) \
byte=byte | bit; \
+RestoreMSCWarning \
bit>>=1; \
if ((int) (bit & 0xff) == 0) \
{ \
const HuffmanTable
*entry;
- ExceptionInfo
- *exception;
-
int
k,
runlength;
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
inject_image->filename);
(void) ResetMagickMemory(scanline,0,width*sizeof(*scanline));
- huffman_image=CloneImage(inject_image,0,0,MagickTrue,&image->exception);
+ huffman_image=CloneImage(inject_image,0,0,MagickTrue,exception);
if (huffman_image == (Image *) NULL)
{
scanline=(unsigned char *) RelinquishMagickMemory(scanline);
return(MagickFalse);
}
- (void) SetImageType(huffman_image,BilevelType);
+ (void) SetImageType(huffman_image,BilevelType,exception);
byte='\0';
bit=(unsigned char) 0x80;
if (LocaleCompare(image_info->magick,"FAX") != 0)
/*
Compress to 1D Huffman pixels.
*/
- exception=(&huffman_image->exception);
q=scanline;
for (y=0; y < (ssize_t) huffman_image->rows; y++)
{
for (x=0; x < (ssize_t) huffman_image->columns; x++)
{
*q++=(unsigned char) (GetPixelIntensity(huffman_image,p) >=
- ((MagickRealType) QuantumRange/2.0) ? 0 : 1);
+ ((double) QuantumRange/2.0) ? 0 : 1);
p+=GetPixelChannels(huffman_image);
}
/*
% The format of the LZWEncodeImage method is:
%
% MagickBooleanType LZWEncodeImage(Image *image,const size_t length,
-% unsigned char *pixels)
+% unsigned char *restrict pixels,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o pixels: the address of an unsigned array of characters containing the
% pixels to compress.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType LZWEncodeImage(Image *image,const size_t length,
- unsigned char *pixels)
+ unsigned char *restrict pixels,ExceptionInfo *exception)
{
#define LZWClr 256UL /* Clear Table Marker */
#define LZWEod 257UL /* End of Data marker */
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
assert(pixels != (unsigned char *) NULL);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
table=(TableType *) AcquireQuantumMemory(1UL << 12,sizeof(*table));
if (table == (TableType *) NULL)
return(MagickFalse);
% The format of the PackbitsEncodeImage method is:
%
% MagickBooleanType PackbitsEncodeImage(Image *image,const size_t length,
-% unsigned char *pixels)
+% unsigned char *restrict pixels)
%
% A description of each parameter follows:
%
%
*/
MagickExport MagickBooleanType PackbitsEncodeImage(Image *image,
- const size_t length,unsigned char *pixels)
+ const size_t length,unsigned char *restrict pixels,ExceptionInfo *exception)
{
int
count;
% The format of the ZLIBEncodeImage method is:
%
% MagickBooleanType ZLIBEncodeImage(Image *image,const size_t length,
-% unsigned char *pixels)
+% unsigned char *restrict pixels,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o pixels: the address of an unsigned array of characters containing the
% pixels to compress.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
static voidpf AcquireZIPMemory(voidpf context,unsigned int items,
}
MagickExport MagickBooleanType ZLIBEncodeImage(Image *image,const size_t length,
- unsigned char *pixels)
+ unsigned char *restrict pixels,ExceptionInfo *exception)
{
int
status;
}
#else
MagickExport MagickBooleanType ZLIBEncodeImage(Image *image,
- const size_t magick_unused(length),unsigned char *magick_unused(pixels))
+ const size_t magick_unused(length),unsigned char *magick_unused(pixels),
+ ExceptionInfo *exception)
{
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
- MissingDelegateError,"DelegateLibrarySupportNotBuiltIn","`%s' (ZIP)",
- image->filename);
+ (void) ThrowMagickException(exception,GetMagickModule(),MissingDelegateError,
+ "DelegateLibrarySupportNotBuiltIn","'%s' (ZIP)",image->filename);
return(MagickFalse);
}
#endif