static Image *ReadDCMImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
-#define ThrowDCMReaderException(exception,message) \
+#define ThrowDCMException(exception,message) \
{ \
if (data != (unsigned char *) NULL) \
data=(unsigned char *) RelinquishMagickMemory(data); \
data=(unsigned char *) NULL;
stream_info=(DCMStreamInfo *) AcquireMagickMemory(sizeof(*stream_info));
if (stream_info == (DCMStreamInfo *) NULL)
- ThrowDCMReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
(void) ResetMagickMemory(stream_info,0,sizeof(*stream_info));
count=ReadBlob(image,128,(unsigned char *) magick);
if (count != 128)
- ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+ ThrowDCMException(CorruptImageError,"ImproperImageHeader");
count=ReadBlob(image,4,(unsigned char *) magick);
if ((count != 4) || (LocaleNCompare(magick,"DICM",4) != 0))
{
offset=SeekBlob(image,0L,SEEK_SET);
if (offset < 0)
- ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+ ThrowDCMException(CorruptImageError,"ImproperImageHeader");
}
/*
Read DCM Medical image.
(void) CopyMagickString(implicit_vr,dicom_info[i].vr,MagickPathExtent);
count=ReadBlob(image,2,(unsigned char *) explicit_vr);
if (count != 2)
- ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+ ThrowDCMException(CorruptImageError,"ImproperImageHeader");
/*
Check for "explicitness", but meta-file headers always explicit.
*/
{
offset=SeekBlob(image,(MagickOffsetType) -2,SEEK_CUR);
if (offset < 0)
- ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+ ThrowDCMException(CorruptImageError,"ImproperImageHeader");
quantum=4;
}
else
data=(unsigned char *) AcquireQuantumMemory(length+1,quantum*
sizeof(*data));
if (data == (unsigned char *) NULL)
- ThrowDCMReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
+ ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
count=ReadBlob(image,(size_t) quantum*length,data);
if (count != (ssize_t) (quantum*length))
{
(void) FormatLocaleFile(stdout,"count=%d quantum=%d "
"length=%d group=%d\n",(int) count,(int) quantum,(int)
length,(int) group);
- ThrowDCMReaderException(CorruptImageError,
+ ThrowDCMException(CorruptImageError,
"InsufficientImageDataInFile");
}
data[length*quantum]='\0';
count=(ssize_t) sscanf(transfer_syntax+17,".%d.%d",&type,
&subtype);
if (count < 1)
- ThrowDCMReaderException(CorruptImageError,
+ ThrowDCMException(CorruptImageError,
"ImproperImageHeader");
}
switch (type)
info.bytes_per_pixel=2;
info.depth=info.bits_allocated;
if (info.depth > 32)
- ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+ ThrowDCMException(CorruptImageError,"ImproperImageHeader");
info.max_value=(1UL << info.bits_allocated)-1;
image->depth=info.depth;
break;
info.bytes_per_pixel=2;
info.depth=info.significant_bits;
if (info.depth > 32)
- ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+ ThrowDCMException(CorruptImageError,"ImproperImageHeader");
info.max_value=(1UL << info.significant_bits)-1;
info.mask=(size_t) GetQuantumRange(info.significant_bits);
image->depth=info.depth;
graymap=(int *) AcquireQuantumMemory((size_t) colors,
sizeof(*graymap));
if (graymap == (int *) NULL)
- ThrowDCMReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
+ ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
for (i=0; i < (ssize_t) colors; i++)
if (info.bytes_per_pixel == 1)
graymap[i]=(int) data[i];
redmap=(int *) AcquireQuantumMemory((size_t) colors,
sizeof(*redmap));
if (redmap == (int *) NULL)
- ThrowDCMReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
+ ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
p=data;
for (i=0; i < (ssize_t) colors; i++)
{
greenmap=(int *) AcquireQuantumMemory((size_t) colors,
sizeof(*greenmap));
if (greenmap == (int *) NULL)
- ThrowDCMReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
+ ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
p=data;
for (i=0; i < (ssize_t) colors; i++)
{
bluemap=(int *) AcquireQuantumMemory((size_t) colors,
sizeof(*bluemap));
if (bluemap == (int *) NULL)
- ThrowDCMReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
+ ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
p=data;
for (i=0; i < (ssize_t) colors; i++)
{
}
}
if ((width == 0) || (height == 0))
- ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+ ThrowDCMException(CorruptImageError,"ImproperImageHeader");
image->columns=(size_t) width;
image->rows=(size_t) height;
if (info.signed_data == 0xffff)
stream_info->offsets=(ssize_t *) AcquireQuantumMemory(
stream_info->offset_count,sizeof(*stream_info->offsets));
if (stream_info->offsets == (ssize_t *) NULL)
- ThrowDCMReaderException(ResourceLimitError,
- "MemoryAllocationFailed");
+ ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
for (i=0; i < (ssize_t) stream_info->offset_count; i++)
stream_info->offsets[i]=(ssize_t) ReadBlobLSBSignedLong(image);
offset=TellBlob(image);
if (tag == 0xFFFEE0DD)
break; /* sequence delimiter tag */
if (tag != 0xFFFEE000)
- ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+ ThrowDCMException(CorruptImageError,"ImproperImageHeader");
file=(FILE *) NULL;
unique_file=AcquireUniqueFileResource(filename);
if (unique_file != -1)
length=(size_t) (GetQuantumRange(info.depth)+1);
info.scale=(Quantum *) AcquireQuantumMemory(length,sizeof(*info.scale));
if (info.scale == (Quantum *) NULL)
- ThrowDCMReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
range=GetQuantumRange(info.depth);
for (i=0; i <= (ssize_t) GetQuantumRange(info.depth); i++)
info.scale[i]=ScaleAnyToQuantum((size_t) i,range);
stream_info->offsets=(ssize_t *) AcquireQuantumMemory(
stream_info->offset_count,sizeof(*stream_info->offsets));
if (stream_info->offsets == (ssize_t *) NULL)
- ThrowDCMReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
for (i=0; i < (ssize_t) stream_info->offset_count; i++)
stream_info->offsets[i]=(ssize_t) ReadBlobLSBSignedLong(image);
offset=TellBlob(image)+8;
if (colors == 0)
colors=one << info.depth;
if (AcquireImageColormap(image,one << info.depth,exception) == MagickFalse)
- ThrowDCMReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ ThrowDCMException(ResourceLimitError,"MemoryAllocationFailed");
if (redmap != (int *) NULL)
for (i=0; i < (ssize_t) colors; i++)
{
stream_info->remaining=(size_t) ReadBlobLSBLong(image);
if ((tag != 0xFFFEE000) || (stream_info->remaining <= 64) ||
(EOFBlob(image) != MagickFalse))
- ThrowDCMReaderException(CorruptImageError,"ImproperImageHeader");
+ ThrowDCMException(CorruptImageError,"ImproperImageHeader");
stream_info->count=0;
stream_info->segment_count=ReadBlobLSBLong(image);
for (i=0; i < 15; i++)