% November 2001 %
% %
% %
-% Copyright 1999-2014 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2015 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 %
%
*/
-static inline size_t MagickMin(const size_t x,const size_t y)
-{
- if (x < y)
- return(x);
- return(y);
-}
-
static char *ReadBlobStringWithLongSize(Image *image,char *string,size_t max,
ExceptionInfo *exception)
{
length=(size_t) ((*xcfdata << 8) + xcfdata[1]);
xcfdata+=2;
}
- size-=length;
- if (size < 0)
- goto bogus_rle;
- if (&xcfdata[length-1] > xcfdatalimit)
- goto bogus_rle;
- while (length-- > 0)
+ size-=length;
+ if (size < 0)
+ goto bogus_rle;
+ if (&xcfdata[length-1] > xcfdatalimit)
+ goto bogus_rle;
+ while (length-- > 0)
+ {
+ data=(*xcfdata++);
+ switch (i)
{
- data=(*xcfdata++);
- switch (i)
+ case 0:
{
- case 0:
- {
- if (inDocInfo->image_type != GIMP_GRAY)
- {
- SetPixelRed(tile_image,ScaleCharToQuantum(data),q);
- SetPixelGreen(tile_image,ScaleCharToQuantum(data),q);
- SetPixelBlue(tile_image,ScaleCharToQuantum(data),q);
- SetPixelAlpha(tile_image,data == 255U ? alpha :
- ScaleCharToQuantum(data),q);
- }
- else
- {
- SetPixelGray(tile_image,ScaleCharToQuantum(data),q);
- SetPixelAlpha(tile_image,data == 255U ? alpha :
- ScaleCharToQuantum(data),q);
- }
- break;
- }
- case 1:
- {
+ if (inDocInfo->image_type == GIMP_GRAY)
+ SetPixelGray(tile_image,ScaleCharToQuantum(data),q);
+ else
+ {
+ SetPixelRed(tile_image,ScaleCharToQuantum(data),q);
+ SetPixelGreen(tile_image,ScaleCharToQuantum(data),q);
+ SetPixelBlue(tile_image,ScaleCharToQuantum(data),q);
+ }
+ SetPixelAlpha(tile_image,alpha,q);
+ break;
+ }
+ case 1:
+ {
+ if (inDocInfo->image_type == GIMP_GRAY)
+ SetPixelAlpha(tile_image,ScaleCharToQuantum(data),q);
+ else
SetPixelGreen(tile_image,ScaleCharToQuantum(data),q);
- break;
- }
- case 2:
- {
- SetPixelBlue(tile_image,ScaleCharToQuantum(data),q);
- break;
- }
- case 3:
- {
- SetPixelAlpha(tile_image,data == 255U ? alpha :
- ScaleCharToQuantum(data),q);
- break;
- }
+ break;
+ }
+ case 2:
+ {
+ SetPixelBlue(tile_image,ScaleCharToQuantum(data),q);
+ break;
+ }
+ case 3:
+ {
+ SetPixelAlpha(tile_image,ScaleCharToQuantum(data),q);
+ break;
}
- q+=GetPixelChannels(tile_image);
}
+ q+=GetPixelChannels(tile_image);
}
- else
+ }
+ else
+ {
+ length+=1;
+ if (length == 128)
+ {
+ if (xcfdata >= xcfdatalimit)
+ goto bogus_rle;
+ length=(size_t) ((*xcfdata << 8) + xcfdata[1]);
+ xcfdata+=2;
+ }
+ size-=length;
+ if (size < 0)
+ goto bogus_rle;
+ if (xcfdata > xcfdatalimit)
+ goto bogus_rle;
+ pixel=(*xcfdata++);
+ for (j=0; j < (ssize_t) length; j++)
{
- length+=1;
- if (length == 128)
+ data=pixel;
+ switch (i)
+ {
+ case 0:
{
- if (xcfdata >= xcfdatalimit)
- goto bogus_rle;
- length=(size_t) ((*xcfdata << 8) + xcfdata[1]);
- xcfdata+=2;
+ if (inDocInfo->image_type == GIMP_GRAY)
+ SetPixelGray(tile_image,ScaleCharToQuantum(data),q);
+ else
+ {
+ SetPixelRed(tile_image,ScaleCharToQuantum(data),q);
+ SetPixelGreen(tile_image,ScaleCharToQuantum(data),q);
+ SetPixelBlue(tile_image,ScaleCharToQuantum(data),q);
+ }
+ SetPixelAlpha(tile_image,alpha,q);
+ break;
}
- size-=length;
- if (size < 0)
- goto bogus_rle;
- if (xcfdata > xcfdatalimit)
- goto bogus_rle;
- pixel=(*xcfdata++);
- for (j=0; j < (ssize_t) length; j++)
- {
- data=pixel;
- switch (i)
+ case 1:
{
- case 0:
- {
- if (inDocInfo->image_type != GIMP_GRAY)
- {
- SetPixelRed(tile_image,ScaleCharToQuantum(data),q);
- SetPixelGreen(tile_image,ScaleCharToQuantum(data),q);
- SetPixelBlue(tile_image,ScaleCharToQuantum(data),q);
- SetPixelAlpha(tile_image,data == 255U ? alpha :
- ScaleCharToQuantum(data),q);
- }
- else
- {
- SetPixelGray(tile_image,ScaleCharToQuantum(data),q);
- SetPixelAlpha(tile_image,data == 255U ? alpha :
- ScaleCharToQuantum(data),q);
- }
- break;
- }
- case 1:
- {
+ if (inDocInfo->image_type == GIMP_GRAY)
+ SetPixelAlpha(tile_image,ScaleCharToQuantum(data),q);
+ else
SetPixelGreen(tile_image,ScaleCharToQuantum(data),q);
- break;
- }
- case 2:
- {
- SetPixelBlue(tile_image,ScaleCharToQuantum(data),q);
- break;
- }
- case 3:
- {
- SetPixelAlpha(tile_image,data == 255U ? alpha :
- ScaleCharToQuantum(data),q);
- break;
- }
+ break;
+ }
+ case 2:
+ {
+ SetPixelBlue(tile_image,ScaleCharToQuantum(data),q);
+ break;
+ }
+ case 3:
+ {
+ SetPixelAlpha(tile_image,ScaleCharToQuantum(data),q);
+ break;
}
- q+=GetPixelChannels(tile_image);
}
+ q+=GetPixelChannels(tile_image);
}
- }
- if (SyncAuthenticPixels(tile_image,exception) == MagickFalse)
- break;
+ }
}
+ if (SyncAuthenticPixels(tile_image,exception) == MagickFalse)
+ break;
+ }
xcfodata=(unsigned char *) RelinquishMagickMemory(xcfodata);
return(MagickTrue);
return((Image *) NULL);
}
count=ReadBlob(image,14,(unsigned char *) magick);
- if ((count == 0) ||
+ if ((count != 14) ||
(LocaleNCompare((char *) magick,"gimp xcf",8) != 0))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
(void) ResetMagickMemory(&doc_info,0,sizeof(XCFDocInfo));
XCFLayerInfo
*layer_info;
+ status=SetImageExtent(image,image->columns,image->rows,exception);
+ if (status == MagickFalse)
+ return(DestroyImageList(image));
/*
the read pointer
*/
entry->magick=(IsImageFormatHandler *) IsXCF;
entry->description=ConstantString("GIMP image");
entry->module=ConstantString("XCF");
- entry->seekable_stream=MagickTrue;
+ entry->flags|=CoderSeekableStreamFlag;
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}