% November 2001 %
% %
% %
-% Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2012 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 "magick/studio.h"
-#include "magick/blob.h"
-#include "magick/blob-private.h"
-#include "magick/cache.h"
-#include "magick/color.h"
-#include "magick/composite.h"
-#include "magick/exception.h"
-#include "magick/exception-private.h"
-#include "magick/image.h"
-#include "magick/image-private.h"
-#include "magick/list.h"
-#include "magick/magick.h"
-#include "magick/memory_.h"
-#include "magick/quantize.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/color.h"
+#include "MagickCore/composite.h"
+#include "MagickCore/exception.h"
+#include "MagickCore/exception-private.h"
+#include "MagickCore/image.h"
+#include "MagickCore/image-private.h"
+#include "MagickCore/list.h"
+#include "MagickCore/magick.h"
+#include "MagickCore/memory_.h"
+#include "MagickCore/pixel.h"
+#include "MagickCore/pixel-accessor.h"
+#include "MagickCore/quantize.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
\f
/*
Typedef declarations.
size_t
file_size;
- ExceptionInfo
- *exception;
+ size_t
+ number_layers;
} XCFDocInfo;
typedef struct
width,
height,
type,
- opacity,
+ alpha,
visible,
linked,
preserve_trans,
red,
green,
blue,
- opacity;
-} XCFPixelPacket;
+ alpha;
+} XCFPixelInfo;
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
case GIMP_SCREEN_MODE: return( ScreenCompositeOp );
case GIMP_OVERLAY_MODE: return( OverlayCompositeOp );
case GIMP_DIFFERENCE_MODE: return( DifferenceCompositeOp );
- case GIMP_ADDITION_MODE: return( AddCompositeOp );
- case GIMP_SUBTRACT_MODE: return( SubtractCompositeOp );
+ case GIMP_ADDITION_MODE: return( ModulusAddCompositeOp );
+ case GIMP_SUBTRACT_MODE: return( ModulusSubtractCompositeOp );
case GIMP_DARKEN_ONLY_MODE: return( DarkenCompositeOp );
case GIMP_LIGHTEN_ONLY_MODE:return( LightenCompositeOp );
case GIMP_HUE_MODE: return( HueCompositeOp );
case GIMP_DODGE_MODE: return( ColorDodgeCompositeOp );
case GIMP_BURN_MODE: return( ColorBurnCompositeOp );
case GIMP_HARDLIGHT_MODE: return( HardLightCompositeOp );
- case GIMP_DIVIDE_MODE: return( DivideCompositeOp );
+ case GIMP_DIVIDE_MODE: return( DivideDstCompositeOp );
/* these are the ones we don't support...yet */
case GIMP_BEHIND_MODE: return( OverCompositeOp );
case GIMP_VALUE_MODE: return( OverCompositeOp );
return(y);
}
-static char *ReadBlobStringWithLongSize(Image *image,char *string,size_t max)
+static char *ReadBlobStringWithLongSize(Image *image,char *string,size_t max,
+ ExceptionInfo *exception)
{
int
c;
string[i]='\0';
offset=SeekBlob(image,(MagickOffsetType) (length-i),SEEK_CUR);
if (offset < 0)
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
+ (void) ThrowMagickException(exception,GetMagickModule(),
CorruptImageError,"ImproperImageHeader","`%s'",image->filename);
return(string);
}
static MagickBooleanType load_tile(Image *image,Image *tile_image,
- XCFDocInfo *inDocInfo,XCFLayerInfo *inLayerInfo,size_t data_length)
+ XCFDocInfo *inDocInfo,XCFLayerInfo *inLayerInfo,size_t data_length,
+ ExceptionInfo *exception)
{
- ExceptionInfo
- *exception;
-
ssize_t
y;
register ssize_t
x;
- register PixelPacket
+ register Quantum
*q;
ssize_t
unsigned char
*graydata;
- XCFPixelPacket
+ XCFPixelInfo
*xcfdata,
*xcfodata;
- xcfdata=(XCFPixelPacket *) AcquireQuantumMemory(data_length,sizeof(*xcfdata));
- if (xcfdata == (XCFPixelPacket *) NULL)
+ xcfdata=(XCFPixelInfo *) AcquireQuantumMemory(data_length,sizeof(*xcfdata));
+ if (xcfdata == (XCFPixelInfo *) NULL)
ThrowBinaryException(ResourceLimitError,"MemoryAllocationFailed",
image->filename);
xcfodata=xcfdata;
if (count != (ssize_t) data_length)
ThrowBinaryException(CorruptImageError,"NotEnoughPixelData",
image->filename);
- exception=(&image->exception);
for (y=0; y < (ssize_t) tile_image->rows; y++)
{
- q=QueueAuthenticPixels(tile_image,0,y,tile_image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ q=GetAuthenticPixels(tile_image,0,y,tile_image->columns,1,exception);
+ if (q == (Quantum *) NULL)
break;
if (inDocInfo->image_type == GIMP_GRAY)
{
for (x=0; x < (ssize_t) tile_image->columns; x++)
{
- q->red=ScaleCharToQuantum(*graydata);
- q->green=q->red;
- q->blue=q->red;
- q->opacity=ScaleCharToQuantum((unsigned char) (255-
- inLayerInfo->opacity));
+ SetPixelGray(tile_image,ScaleCharToQuantum(*graydata),q);
+ SetPixelAlpha(tile_image,ScaleCharToQuantum((unsigned char)
+ inLayerInfo->alpha),q);
graydata++;
- q++;
+ q+=GetPixelChannels(tile_image);
}
}
else
{
for (x=0; x < (ssize_t) tile_image->columns; x++)
{
- q->red=ScaleCharToQuantum(xcfdata->red);
- q->green=ScaleCharToQuantum(xcfdata->green);
- q->blue=ScaleCharToQuantum(xcfdata->blue);
- q->opacity=(Quantum) (xcfdata->opacity == 0U ? TransparentOpacity :
- ScaleCharToQuantum((unsigned char) (255-inLayerInfo->opacity)));
+ SetPixelRed(tile_image,ScaleCharToQuantum(xcfdata->red),q);
+ SetPixelGreen(tile_image,ScaleCharToQuantum(xcfdata->green),q);
+ SetPixelBlue(tile_image,ScaleCharToQuantum(xcfdata->blue),q);
+ SetPixelAlpha(tile_image,xcfdata->alpha == 255U ? TransparentAlpha :
+ ScaleCharToQuantum((unsigned char) inLayerInfo->alpha),q);
xcfdata++;
- q++;
+ q+=GetPixelChannels(tile_image);
}
}
if (SyncAuthenticPixels(tile_image,exception) == MagickFalse)
break;
}
- xcfodata=(XCFPixelPacket *) RelinquishMagickMemory(xcfodata);
+ xcfodata=(XCFPixelInfo *) RelinquishMagickMemory(xcfodata);
return MagickTrue;
}
static MagickBooleanType load_tile_rle(Image *image,Image *tile_image,
- XCFDocInfo *inDocInfo,XCFLayerInfo *inLayerInfo,size_t data_length)
+ XCFDocInfo *inDocInfo,XCFLayerInfo *inLayerInfo,size_t data_length,
+ ExceptionInfo *exception)
{
- ExceptionInfo
- *exception;
-
- ssize_t
- i,
- j;
-
MagickOffsetType
size;
- register PixelPacket
- *q;
+ Quantum
+ alpha;
- ssize_t
- bytes_per_pixel,
- count;
+ register Quantum
+ *q;
size_t
length;
+ ssize_t
+ bytes_per_pixel,
+ count,
+ i,
+ j;
+
unsigned char
data,
pixel,
xcfodata=xcfdata;
count=ReadBlob(image, (size_t) data_length, xcfdata);
xcfdatalimit = xcfodata+count-1;
- exception=(&image->exception);
+ alpha=ScaleCharToQuantum((unsigned char) inLayerInfo->alpha);
for (i=0; i < (ssize_t) bytes_per_pixel; i++)
{
q=GetAuthenticPixels(tile_image,0,0,tile_image->columns,tile_image->rows,
exception);
+ if (q == (Quantum *) NULL)
+ continue;
size=(MagickOffsetType) tile_image->rows*tile_image->columns;
while (size > 0)
{
{
case 0:
{
- q->red=ScaleCharToQuantum(data);
- if (inDocInfo->image_type == GIMP_GRAY)
+ if (inDocInfo->image_type != GIMP_GRAY)
{
- q->green=ScaleCharToQuantum(data);
- q->blue=ScaleCharToQuantum(data);
- q->opacity=ScaleCharToQuantum((unsigned char) (255-
- inLayerInfo->opacity));
+ 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
{
- q->green= q->red;
- q->blue= q->red;
- q->opacity=ScaleCharToQuantum((unsigned char) (255-
- inLayerInfo->opacity));
+ SetPixelGray(tile_image,ScaleCharToQuantum(data),q);
+ SetPixelAlpha(tile_image,data == 255U ? alpha :
+ ScaleCharToQuantum(data),q);
}
break;
}
case 1:
{
- q->green=ScaleCharToQuantum(data);
+ SetPixelGreen(tile_image,ScaleCharToQuantum(data),q);
break;
}
case 2:
{
- q->blue=ScaleCharToQuantum(data);
+ SetPixelBlue(tile_image,ScaleCharToQuantum(data),q);
break;
}
case 3:
{
- q->opacity=(Quantum) (data == 0 ? TransparentOpacity :
- ScaleCharToQuantum((unsigned char) (255-
- inLayerInfo->opacity)));
+ SetPixelAlpha(tile_image,data == 255U ? alpha :
+ ScaleCharToQuantum(data),q);
break;
}
}
- q++;
+ q+=GetPixelChannels(tile_image);
}
}
else
if (xcfdata > xcfdatalimit)
goto bogus_rle;
pixel=(*xcfdata++);
- for (j= 0; j < (ssize_t) length; j++)
+ for (j=0; j < (ssize_t) length; j++)
{
data=pixel;
switch (i)
{
case 0:
{
- q->red=ScaleCharToQuantum(data);
- if (inDocInfo->image_type == GIMP_GRAY)
+ if (inDocInfo->image_type != GIMP_GRAY)
{
- q->green=ScaleCharToQuantum(data);
- q->blue=ScaleCharToQuantum(data);
- q->opacity=ScaleCharToQuantum((unsigned char) (255-
- inLayerInfo->opacity));
+ 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
{
- q->green=q->red;
- q->blue=q->red;
- q->opacity=ScaleCharToQuantum((unsigned char) (255-
- inLayerInfo->opacity));
+ SetPixelGray(tile_image,ScaleCharToQuantum(data),q);
+ SetPixelAlpha(tile_image,data == 255U ? alpha :
+ ScaleCharToQuantum(data),q);
}
break;
}
case 1:
{
- q->green=ScaleCharToQuantum(data);
+ SetPixelGreen(tile_image,ScaleCharToQuantum(data),q);
break;
}
case 2:
{
- q->blue=ScaleCharToQuantum(data);
+ SetPixelBlue(tile_image,ScaleCharToQuantum(data),q);
break;
}
case 3:
{
- q->opacity=(Quantum) (data == 0 ? TransparentOpacity :
- ScaleCharToQuantum((unsigned char) (255-
- inLayerInfo->opacity)));
+ SetPixelAlpha(tile_image,data == 255U ? alpha :
+ ScaleCharToQuantum(data),q);
break;
}
}
- q++;
+ q+=GetPixelChannels(tile_image);
}
}
}
}
static MagickBooleanType load_level(Image *image,XCFDocInfo *inDocInfo,
- XCFLayerInfo *inLayerInfo)
+ XCFLayerInfo *inLayerInfo,ExceptionInfo *exception)
{
- ExceptionInfo
- *exception;
-
int
destLeft = 0,
destTop = 0;
tile_image_height;
/* start reading the data */
- exception=inDocInfo->exception;
width=ReadBlobMSBLong(image);
height=ReadBlobMSBLong(image);
/* seek to the tile offset */
offset=SeekBlob(image, offset, SEEK_SET);
- /* allocate the image for the tile
- NOTE: the last tile in a row or column may not be a full tile!
+ /*
+ Allocate the image for the tile. NOTE: the last tile in a row or
+ column may not be a full tile!
*/
tile_image_width=(size_t) (destLeft == (int) ntile_cols-1 ?
(int) width % TILE_WIDTH : TILE_WIDTH);
- if (tile_image_width == 0) tile_image_width=TILE_WIDTH;
+ if (tile_image_width == 0)
+ tile_image_width=TILE_WIDTH;
tile_image_height = (size_t) (destTop == (int) ntile_rows-1 ?
(int) height % TILE_HEIGHT : TILE_HEIGHT);
- if (tile_image_height == 0) tile_image_height=TILE_HEIGHT;
+ if (tile_image_height == 0)
+ tile_image_height=TILE_HEIGHT;
tile_image=CloneImage(inLayerInfo->image,tile_image_width,
tile_image_height,MagickTrue,exception);
switch (inDocInfo->compression)
{
case COMPRESS_NONE:
- if (load_tile(image,tile_image,inDocInfo,inLayerInfo,(size_t) (offset2-offset)) == 0)
+ if (load_tile(image,tile_image,inDocInfo,inLayerInfo,(size_t) (offset2-offset),exception) == 0)
status=MagickTrue;
break;
case COMPRESS_RLE:
if (load_tile_rle (image,tile_image,inDocInfo,inLayerInfo,
- (int) (offset2-offset)) == 0)
+ (int) (offset2-offset),exception) == 0)
status=MagickTrue;
break;
case COMPRESS_ZLIB:
}
/* composite the tile onto the layer's image, and then destroy it */
- (void) CompositeImage(inLayerInfo->image,CopyCompositeOp,tile_image,
- destLeft * TILE_WIDTH,destTop*TILE_HEIGHT);
+ (void) CompositeImage(inLayerInfo->image,tile_image,CopyCompositeOp,
+ MagickTrue,destLeft * TILE_WIDTH,destTop*TILE_HEIGHT,exception);
tile_image=DestroyImage(tile_image);
/* adjust tile position */
}
static MagickBooleanType load_hierarchy(Image *image,XCFDocInfo *inDocInfo,
- XCFLayerInfo *inLayer)
+ XCFLayerInfo *inLayer, ExceptionInfo *exception)
{
MagickOffsetType
saved_pos,
bytes_per_pixel;
width=ReadBlobMSBLong(image);
+ (void) width;
height=ReadBlobMSBLong(image);
+ (void) height;
bytes_per_pixel=inDocInfo->bytes_per_pixel=ReadBlobMSBLong(image);
+ (void) bytes_per_pixel;
/* load in the levels...we make sure that the number of levels
* calculated when the TileManager was created is the same
offset=SeekBlob(image, offset, SEEK_SET);
/* read in the level */
- if (load_level (image, inDocInfo, inLayer) == 0)
+ if (load_level (image, inDocInfo, inLayer, exception) == 0)
return(MagickFalse);
/* restore the saved position so we'll be ready to
* read the next offset.
return(MagickTrue);
}
-static MagickBooleanType ReadOneLayer(Image* image,XCFDocInfo* inDocInfo,
- XCFLayerInfo *outLayer )
+static MagickBooleanType ReadOneLayer(const ImageInfo *image_info,Image* image,
+ XCFDocInfo* inDocInfo,XCFLayerInfo *outLayer,const ssize_t layer,
+ ExceptionInfo *exception )
{
- ssize_t
- i;
-
MagickOffsetType
offset;
outLayer->height = ReadBlobMSBLong(image);
outLayer->type = ReadBlobMSBLong(image);
(void) ReadBlobStringWithLongSize(image, outLayer->name,
- sizeof(outLayer->name));
- /* allocate the image for this layer */
- outLayer->image=CloneImage(image,outLayer->width, outLayer->height,MagickTrue,
- &image->exception);
- if (outLayer->image == (Image *) NULL)
- return MagickFalse;
+ sizeof(outLayer->name),exception);
/* read the layer properties! */
foundPropEnd = 0;
while ( (foundPropEnd == MagickFalse) && (EOFBlob(image) == MagickFalse) ) {
outLayer->floating_offset = ReadBlobMSBLong(image);
break;
case PROP_OPACITY:
- outLayer->opacity = ReadBlobMSBLong(image);
+ outLayer->alpha = ReadBlobMSBLong(image);
break;
case PROP_VISIBLE:
outLayer->visible = ReadBlobMSBLong(image);
outLayer->show_mask = ReadBlobMSBLong(image);
break;
case PROP_OFFSETS:
- outLayer->offset_x = (ssize_t) ReadBlobMSBLong(image);
- outLayer->offset_y = (ssize_t) ReadBlobMSBLong(image);
+ outLayer->offset_x = (int) ReadBlobMSBLong(image);
+ outLayer->offset_y = (int) ReadBlobMSBLong(image);
break;
case PROP_MODE:
outLayer->mode = ReadBlobMSBLong(image);
break;
case PROP_PARASITES:
{
- for (i=0; i < (ssize_t) prop_size; i++ )
- (void) ReadBlobByte(image);
+ if (DiscardBlobBytes(image,prop_size) == MagickFalse)
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
/*
ssize_t base = info->cp;
if (foundPropEnd == MagickFalse)
return(MagickFalse);
- /* clear the image based on the layer opacity */
- outLayer->image->background_color.opacity=
- ScaleCharToQuantum((unsigned char) (255-outLayer->opacity));
- (void) SetImageBackgroundColor(outLayer->image);
+ /* allocate the image for this layer */
+ if (image_info->number_scenes != 0)
+ {
+ ssize_t
+ scene;
+ scene=inDocInfo->number_layers-layer-1;
+ if (scene > (image_info->scene+image_info->number_scenes-1))
+ {
+ outLayer->image=CloneImage(image,0,0,MagickTrue,exception);
+ if (outLayer->image == (Image *) NULL)
+ return(MagickFalse);
+ outLayer->image->page.x=outLayer->offset_x;
+ outLayer->image->page.y=outLayer->offset_y;
+ outLayer->image->page.width=outLayer->width;
+ outLayer->image->page.height=outLayer->height;
+ return(MagickTrue);
+ }
+ }
+ outLayer->image=CloneImage(image,outLayer->width, outLayer->height,MagickTrue,
+ exception);
+ if (outLayer->image == (Image *) NULL)
+ return(MagickFalse);
+ /* clear the image based on the layer opacity */
+ outLayer->image->background_color.alpha=
+ ScaleCharToQuantum((unsigned char) outLayer->alpha);
+ (void) SetImageBackgroundColor(outLayer->image,exception);
+
+ outLayer->image->page.x=outLayer->offset_x;
+ outLayer->image->page.y=outLayer->offset_y;
+ outLayer->image->page.width=outLayer->width;
+ outLayer->image->page.height=outLayer->height;
/* set the compositing mode */
outLayer->image->compose = GIMPBlendModeToCompositeOperator( outLayer->mode );
if ( outLayer->visible == MagickFalse )
/* read in the hierarchy */
offset=SeekBlob(image, (MagickOffsetType) hierarchy_offset, SEEK_SET);
if (offset < 0)
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
+ (void) ThrowMagickException(exception,GetMagickModule(),
CorruptImageError,"InvalidImageHeader","`%s'",image->filename);
- if (load_hierarchy (image, inDocInfo, outLayer) == 0)
+ if (load_hierarchy (image, inDocInfo, outLayer, exception) == 0)
return(MagickFalse);
/* read in the layer mask */
return MagickTrue;
}
-
+\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
%
% o exception: return any errors or warnings in this structure.
%
-%
*/
static Image *ReadXCFImage(const ImageInfo *image_info,ExceptionInfo *exception)
{
i;
size_t
+ image_type,
length;
ssize_t
count;
- size_t
- image_type;
-
XCFDocInfo
doc_info;
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- image=AcquireImage(image_info);
+ image=AcquireImage(image_info,exception);
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
if (status == MagickFalse)
{
(LocaleNCompare((char *) magick,"gimp xcf",8) != 0))
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
(void) ResetMagickMemory(&doc_info,0,sizeof(XCFDocInfo));
- doc_info.exception=exception;
doc_info.width=ReadBlobMSBLong(image);
doc_info.height=ReadBlobMSBLong(image);
if ((doc_info.width > 262144) || (doc_info.height > 262144))
else
if (image_type == GIMP_INDEXED)
ThrowReaderException(CoderError,"ColormapTypeNotSupported");
- (void) SetImageBackgroundColor(image);
+ (void) SetImageBackgroundColor(image,exception);
image->matte=MagickTrue;
/*
Read properties.
by some Gimp versions.
*/
size_t num_colours = ReadBlobMSBLong(image);
- for (i=0; i < (ssize_t) (3L*num_colours); i++ )
- (void) ReadBlobByte(image);
+ if (DiscardBlobBytes(image,3*num_colours) == MagickFalse)
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
/*
if (info->file_version == 0)
{
case PROP_GUIDES:
{
/* just skip it - we don't care about guides */
- for (i=0; i < (ssize_t) prop_size; i++ )
- if (ReadBlobByte(image) == EOF)
- ThrowFileException(exception,CorruptImageError,
- "UnexpectedEndOfFile",image->filename);
+ if (DiscardBlobBytes(image,prop_size) == MagickFalse)
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
}
break;
/* BOGUS: we don't write these yet because we aren't
reading them properly yet :(
- image->x_resolution = xres;
- image->y_resolution = yres;
+ image->resolution.x = xres;
+ image->resolution.y = yres;
*/
}
break;
case PROP_PARASITES:
{
/* BOGUS: we may need these for IPTC stuff */
- for (i=0; i < (ssize_t) prop_size; i++ )
- if (ReadBlobByte(image) == EOF)
- ThrowFileException(exception,CorruptImageError,
- "UnexpectedEndOfFile",image->filename);
-
+ if (DiscardBlobBytes(image,prop_size) == MagickFalse)
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
/*
gssize_t base = info->cp;
GimpParasite *p;
case PROP_PATHS:
{
/* BOGUS: just skip it for now */
- for (i=0; i< (ssize_t) prop_size; i++ )
- if (ReadBlobByte(image) == EOF)
- ThrowFileException(exception,CorruptImageError,
- "UnexpectedEndOfFile",image->filename);
+ if (DiscardBlobBytes(image,prop_size) == MagickFalse)
+ ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+ image->filename);
/*
PathList *paths = xcf_load_bzpaths (gimage, info);
/* size_t digits = */ (void) ReadBlobMSBLong(image);
for (i=0; i<5; i++)
(void) ReadBlobStringWithLongSize(image, unit_string,
- sizeof(unit_string));
+ sizeof(unit_string),exception);
}
break;
*/
do
{
- ssize_t offset = (ssize_t) ReadBlobMSBLong(image);
+ ssize_t offset = (int) ReadBlobMSBLong(image);
if (offset == 0)
foundAllLayers=MagickTrue;
else
break;
}
} while (foundAllLayers == MagickFalse);
+ doc_info.number_layers=number_layers;
offset=SeekBlob(image,oldPos,SEEK_SET); /* restore the position! */
if (offset < 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
/* seek to the layer offset */
offset=SeekBlob(image,offset,SEEK_SET);
/* read in the layer */
- layer_ok=ReadOneLayer(image,&doc_info,&layer_info[current_layer]);
+ layer_ok=ReadOneLayer(image_info,image,&doc_info,
+ &layer_info[current_layer],current_layer,exception);
if (layer_ok == MagickFalse)
{
int j;
for (j=0; j < current_layer; j++)
layer_info[j].image=DestroyImage(layer_info[j].image);
- ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
- }
+ layer_info=(XCFLayerInfo *) RelinquishMagickMemory(layer_info);
+ ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ }
/* restore the saved position so we'll be ready to
* read the next offset.
*/
/*
Composite the layer data onto the main image, dispose the layer.
*/
- (void) CompositeImage(image,OverCompositeOp,layer_info[0].image,
- layer_info[0].offset_x,layer_info[0].offset_y);
+ (void) CompositeImage(image,layer_info[0].image,OverCompositeOp,
+ MagickTrue,layer_info[0].offset_x,layer_info[0].offset_y,exception);
layer_info[0].image =DestroyImage( layer_info[0].image);
}
else
layer_info[j].offset_x, layer_info[j].offset_y );
layer_info[j].image =DestroyImage( layer_info[j].image );
- /* Bob says that if we do this, we'll get REAL gray images! */
+ /* If we do this, we'll get REAL gray images! */
if ( image_type == GIMP_GRAY ) {
QuantizeInfo qi;
GetQuantizeInfo(&qi);
#else
{
/* NOTE: XCF layers are REVERSED from composite order! */
- signed int j;
+ ssize_t j;
/* first we copy the last layer on top of the main image */
- (void) CompositeImage(image,CopyCompositeOp,
- layer_info[number_layers-1].image,
- layer_info[number_layers-1].offset_x,
- layer_info[number_layers-1].offset_y);
+ (void) CompositeImage(image,layer_info[number_layers-1].image,
+ CopyCompositeOp,MagickTrue,layer_info[number_layers-1].offset_x,
+ layer_info[number_layers-1].offset_y,exception);
layer_info[number_layers-1].image=DestroyImage(
layer_info[number_layers-1].image);
/* now reverse the order of the layers as they are put
into subimages
*/
- j=number_layers-2;
- image->next=layer_info[j].image;
- layer_info[j].image->previous=image;
- layer_info[j].image->page.x=layer_info[j].offset_x;
- layer_info[j].image->page.y=layer_info[j].offset_y;
- layer_info[j].image->page.width=layer_info[j].width;
- layer_info[j].image->page.height=layer_info[j].height;
- for (j=number_layers-3; j>=0; j--)
- {
- if (j > 0)
- layer_info[j].image->next=layer_info[j-1].image;
- if (j < (number_layers-1))
- layer_info[j].image->previous=layer_info[j+1].image;
- layer_info[j].image->page.x=layer_info[j].offset_x;
- layer_info[j].image->page.y=layer_info[j].offset_y;
- layer_info[j].image->page.width=layer_info[j].width;
- layer_info[j].image->page.height=layer_info[j].height;
- }
+ for (j=(ssize_t) number_layers-2; j >= 0; j--)
+ AppendImageToList(&image,layer_info[j].image);
}
#endif
}