unsigned short Version;
char EndianIndicator[2];
unsigned long DataType;
- unsigned long ObjectSize;
+ unsigned int ObjectSize;
unsigned long unknown1;
unsigned long unknown2;
#if defined(MAGICKCORE_ZLIB_DELEGATE)
/** This procedure decompreses an image block for a new MATLAB format. */
-static Image *DecompressBlock(Image *orig, MagickOffsetType Size, ImageInfo *clone_info, ExceptionInfo *exception)
+static Image *DecompressBlock(Image *orig, unsigned int *Size, ImageInfo *clone_info, ExceptionInfo *exception)
{
Image *image2;
int status;
int zip_status;
+ssize_t TotalSize = 0;
if(clone_info==NULL) return NULL;
if(clone_info->file) /* Close file opened from previous transaction. */
(void) remove_utf8(clone_info->filename);
}
- CacheBlock = AcquireQuantumMemory((size_t)((Size<16384)?Size:16384),sizeof(unsigned char *));
+ CacheBlock = AcquireQuantumMemory((size_t)((*Size<16384)?*Size:16384),sizeof(unsigned char *));
if(CacheBlock==NULL) return NULL;
DecompressBlock = AcquireQuantumMemory((size_t)(4096),sizeof(unsigned char *));
if(DecompressBlock==NULL)
zip_info.avail_in = 0;
zip_info.total_out = 0;
- while(Size>0 && !EOFBlob(orig))
+ while(*Size>0 && !EOFBlob(orig))
{
- magick_size = ReadBlob(orig, (Size<16384)?Size:16384, (unsigned char *) CacheBlock);
+ magick_size = ReadBlob(orig, (*Size<16384)?*Size:16384, (unsigned char *) CacheBlock);
zip_info.next_in = (Bytef *) CacheBlock;
zip_info.avail_in = (uInt) magick_size;
break;
extent=fwrite(DecompressBlock, 4096-zip_info.avail_out, 1, mat_file);
(void) extent;
+ TotalSize += 4096-zip_info.avail_out;
if(zip_status == Z_STREAM_END) goto DblBreak;
}
if ((zip_status != Z_OK) && (zip_status != Z_STREAM_END))
break;
- Size -= magick_size;
+ *Size -= magick_size;
}
DblBreak:
(void)fclose(mat_file);
RelinquishMagickMemory(CacheBlock);
RelinquishMagickMemory(DecompressBlock);
+ *Size = TotalSize;
if((clone_info->file=fopen(clone_info->filename,"rb"))==NULL) goto UnlinkFile;
if( (image2 = AcquireImage(clone_info,exception))==NULL ) goto EraseFile;
#if defined(MAGICKCORE_ZLIB_DELEGATE)
if(MATLAB_HDR.DataType == miCOMPRESSED)
{
- image2 = DecompressBlock(image,MATLAB_HDR.ObjectSize,clone_info,exception);
+ image2 = DecompressBlock(image,&MATLAB_HDR.ObjectSize,clone_info,exception);
if(image2==NULL) continue;
MATLAB_HDR.DataType = ReadBlobXXXLong(image2); /* replace compressed object type. */
}