% July 1992 %
% %
% %
-% Copyright 1999-2008 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2013 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/colorspace.h"
-#include "magick/constitute.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/monitor.h"
-#include "magick/monitor-private.h"
-#include "magick/pixel-private.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/statistic.h"
-#include "magick/string_.h"
-#include "magick/module.h"
-#include "magick/utility.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/colorspace.h"
+#include "MagickCore/colorspace-private.h"
+#include "MagickCore/constitute.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/monitor.h"
+#include "MagickCore/monitor-private.h"
+#include "MagickCore/pixel-accessor.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/statistic.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
+#include "MagickCore/utility.h"
\f
/*
Forward declarations.
*/
static MagickBooleanType
- WriteRGBImage(const ImageInfo *,Image *);
+ WriteRGBImage(const ImageInfo *,Image *,ExceptionInfo *);
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% ReadRGBImage() reads an image of raw RGB or RGBA samples and returns it. It
-% allocates the memory necessary for the new Image structure and returns a
-% pointer to the new image.
+% ReadRGBImage() reads an image of raw RGB, RGBA, or RGBO samples and returns
+% it. It allocates the memory necessary for the new Image structure and
+% returns a pointer to the new image.
%
% The format of the ReadRGBImage method is:
%
-% Image *ReadRGBImage(const ImageInfo *image_info,ExceptionInfo *exception)
+% Image *ReadRGBImage(const ImageInfo *image_info,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
*canvas_image,
*image;
- ssize_t
- y;
-
MagickBooleanType
status;
quantum_type;
register ssize_t
- i,
- j;
-
- Quantum
- qx[3];
-
- ssize_t
- count;
+ i;
size_t
length;
+ ssize_t
+ count,
+ y;
+
unsigned char
*pixels;
- QuantumType
- quantum_types[4];
-
- char
- sfx[] = {0, 0};
-
- int
- channels = 3;
-
/*
Open image file.
*/
image_info->filename);
assert(exception != (ExceptionInfo *) NULL);
assert(exception->signature == MagickSignature);
- image=AcquireImage(image_info);
+ image=AcquireImage(image_info,exception);
if ((image->columns == 0) || (image->rows == 0))
ThrowReaderException(OptionError,"MustSpecifyImageSize");
if (image_info->interlace != PartitionInterlace)
image=DestroyImageList(image);
return((Image *) NULL);
}
- for (i=0; i < image->offset; i++)
- if (ReadBlobByte(image) == EOF)
- {
- ThrowFileException(exception,CorruptImageError,
- "UnexpectedEndOfFile",image->filename);
- break;
- }
+ if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+ ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+ image->filename);
}
/*
Create virtual canvas to support cropping (i.e. image.rgb[100x100+10+20]).
*/
canvas_image=CloneImage(image,image->extract_info.width,1,MagickFalse,
exception);
- (void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod);
+ (void) SetImageVirtualPixelMethod(canvas_image,BlackVirtualPixelMethod,
+ exception);
quantum_info=AcquireQuantumInfo(image_info,canvas_image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
if (LocaleCompare(image_info->magick,"RGBA") == 0)
{
quantum_type=RGBAQuantum;
- image->matte=MagickTrue;
- channels=4;
- }
- else if (LocaleCompare(image_info->magick,"BGRA") == 0)
- {
- quantum_type=BGRAQuantum;
- image->matte=MagickTrue;
- channels=4;
+ image->alpha_trait=BlendPixelTrait;
+ canvas_image->alpha_trait=BlendPixelTrait;
}
- else if (LocaleCompare(image_info->magick,"RGBO") == 0)
+ if (LocaleCompare(image_info->magick,"RGBO") == 0)
{
quantum_type=RGBOQuantum;
- image->matte=MagickTrue;
- channels=4;
+ canvas_image->alpha_trait=BlendPixelTrait;
}
if (image_info->number_scenes != 0)
while (image->scene < image_info->scene)
break;
}
}
- for (i=0; i < channels; i++)
- {
- switch(image_info->magick[i])
- {
- case 'R': quantum_types[i]=RedQuantum; break;
- case 'G': quantum_types[i]=GreenQuantum; break;
- case 'B': quantum_types[i]=BlueQuantum; break;
- case 'A': quantum_types[i]=AlphaQuantum; break;
- case 'O': quantum_types[i]=OpacityQuantum; break;
- }
- }
count=0;
length=0;
scene=0;
{
length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
count=ReadBlob(image,length,pixels);
- if (count != (ssize_t) length)
- break;
}
for (y=0; y < (ssize_t) image->extract_info.height; y++)
{
- register const PixelPacket
+ register const Quantum
*restrict p;
+ register Quantum
+ *restrict q;
+
register ssize_t
x;
- register PixelPacket
- *restrict q;
-
if (count != (ssize_t) length)
{
ThrowFileException(exception,CorruptImageError,
}
q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
quantum_info,quantum_type,pixels,exception);
if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
break;
- if (((y-image->extract_info.y) >= 0) &&
+ if (((y-image->extract_info.y) >= 0) &&
((y-image->extract_info.y) < (ssize_t) image->rows))
{
p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
canvas_image->columns,1,exception);
q=QueueAuthenticPixels(image,0,y-image->extract_info.y,
image->columns,1,exception);
- if ((p == (const PixelPacket *) NULL) ||
- (q == (PixelPacket *) NULL))
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- qx[0]=GetRedPixelComponent(p);
- qx[1]=GetGreenPixelComponent(p);
- qx[2]=GetBluePixelComponent(p);
- for (i=0; i < 3; i++)
- switch(quantum_types[i])
- {
- case RedQuantum: q->red=qx[i]; break;
- case GreenQuantum: q->green=qx[i]; break;
- case BlueQuantum: q->blue=qx[i]; break;
- default: break;
- }
- SetOpacityPixelComponent(q,OpaqueOpacity);
- if (image->matte != MagickFalse)
- SetOpacityPixelComponent(q,GetOpacityPixelComponent(p));
- p++;
- q++;
+ SetPixelRed(image,GetPixelRed(canvas_image,p),q);
+ SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
+ SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
+ SetPixelAlpha(image,OpaqueAlpha,q);
+ if (image->alpha_trait == BlendPixelTrait)
+ SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
+ p+=GetPixelChannels(canvas_image);
+ q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
case LineInterlace:
{
+ static QuantumType
+ quantum_types[4] =
+ {
+ RedQuantum,
+ GreenQuantum,
+ BlueQuantum,
+ AlphaQuantum
+ };
+
/*
Line interlacing: RRR...GGG...BBB...RRR...GGG...BBB...
*/
+ if (LocaleCompare(image_info->magick,"RGBO") == 0)
+ quantum_types[3]=OpacityQuantum;
if (scene == 0)
{
- length=GetQuantumExtent(canvas_image,quantum_info,quantum_types[0]);
+ length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
count=ReadBlob(image,length,pixels);
}
for (y=0; y < (ssize_t) image->extract_info.height; y++)
{
- register const PixelPacket
+ register const Quantum
*restrict p;
+ register Quantum
+ *restrict q;
+
register ssize_t
x;
- register PixelPacket
- *restrict q;
-
if (count != (ssize_t) length)
{
ThrowFileException(exception,CorruptImageError,
"UnexpectedEndOfFile",image->filename);
break;
}
- for (i=0; i < channels; i++)
+ for (i=0; i < (ssize_t) (image->alpha_trait == BlendPixelTrait ? 4 : 3); i++)
{
+ quantum_type=quantum_types[i];
q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
- quantum_info,quantum_types[i],pixels,exception);
+ quantum_info,quantum_type,pixels,exception);
if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
break;
- if (((y-image->extract_info.y) >= 0) &&
+ if (((y-image->extract_info.y) >= 0) &&
((y-image->extract_info.y) < (ssize_t) image->rows))
{
p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
0,canvas_image->columns,1,exception);
q=GetAuthenticPixels(image,0,y-image->extract_info.y,
image->columns,1,exception);
- if ((p == (const PixelPacket *) NULL) ||
- (q == (PixelPacket *) NULL))
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
break;
- if (i == (channels - 1))
- for (x=0; x < (ssize_t) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
+ {
+ switch (quantum_type)
{
- SetRedPixelComponent(q,GetRedPixelComponent(p));
- SetGreenPixelComponent(q,GetGreenPixelComponent(p));
- SetBluePixelComponent(q,GetBluePixelComponent(p));
- SetOpacityPixelComponent(q,GetOpacityPixelComponent(p));
- p++;
- q++;
+ case RedQuantum:
+ {
+ SetPixelRed(image,GetPixelRed(canvas_image,p),q);
+ break;
+ }
+ case GreenQuantum:
+ {
+ SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
+ break;
+ }
+ case BlueQuantum:
+ {
+ SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
+ break;
+ }
+ case OpacityQuantum:
+ {
+ SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
+ break;
+ }
+ case AlphaQuantum:
+ {
+ SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
+ break;
+ }
+ default:
+ break;
}
+ p+=GetPixelChannels(canvas_image);
+ q+=GetPixelChannels(image);
+ }
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
*/
if (scene == 0)
{
- length=GetQuantumExtent(canvas_image,quantum_info,quantum_types[0]);
+ length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
count=ReadBlob(image,length,pixels);
}
- for (i=0; i < channels; i++)
+ for (y=0; y < (ssize_t) image->extract_info.height; y++)
{
- for (y=0; y < (ssize_t) image->extract_info.height; y++)
- {
- register const PixelPacket
- *restrict p;
+ register const Quantum
+ *restrict p;
- register ssize_t
- x;
+ register Quantum
+ *restrict q;
- register PixelPacket
- *restrict q;
+ register ssize_t
+ x;
- if (count != (ssize_t) length)
+ if (count != (ssize_t) length)
+ {
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
+ break;
+ }
+ q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
+ exception);
+ if (q == (Quantum *) NULL)
+ break;
+ length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
+ quantum_info,RedQuantum,pixels,exception);
+ if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
+ break;
+ if (((y-image->extract_info.y) >= 0) &&
+ ((y-image->extract_info.y) < (ssize_t) image->rows))
+ {
+ p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
+ canvas_image->columns,1,exception);
+ q=GetAuthenticPixels(image,0,y-image->extract_info.y,
+ image->columns,1,exception);
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
+ break;
+ for (x=0; x < (ssize_t) image->columns; x++)
{
- ThrowFileException(exception,CorruptImageError,
- "UnexpectedEndOfFile",image->filename);
+ SetPixelRed(image,GetPixelRed(canvas_image,p),q);
+ p+=GetPixelChannels(canvas_image);
+ q+=GetPixelChannels(image);
+ }
+ if (SyncAuthenticPixels(image,exception) == MagickFalse)
+ break;
+ }
+ count=ReadBlob(image,length,pixels);
+ }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,LoadImageTag,1,6);
+ if (status == MagickFalse)
+ break;
+ }
+ for (y=0; y < (ssize_t) image->extract_info.height; y++)
+ {
+ register const Quantum
+ *restrict p;
+
+ register Quantum
+ *restrict q;
+
+ register ssize_t
+ x;
+
+ if (count != (ssize_t) length)
+ {
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
+ break;
+ }
+ q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
+ exception);
+ if (q == (Quantum *) NULL)
+ break;
+ length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
+ quantum_info,GreenQuantum,pixels,exception);
+ if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
+ break;
+ if (((y-image->extract_info.y) >= 0) &&
+ ((y-image->extract_info.y) < (ssize_t) image->rows))
+ {
+ p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
+ canvas_image->columns,1,exception);
+ q=GetAuthenticPixels(image,0,y-image->extract_info.y,
+ image->columns,1,exception);
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
break;
+ for (x=0; x < (ssize_t) image->columns; x++)
+ {
+ SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
+ p+=GetPixelChannels(canvas_image);
+ q+=GetPixelChannels(image);
}
- q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
- exception);
- if (q == (PixelPacket *) NULL)
+ if (SyncAuthenticPixels(image,exception) == MagickFalse)
+ break;
+ }
+ count=ReadBlob(image,length,pixels);
+ }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,LoadImageTag,2,6);
+ if (status == MagickFalse)
break;
- length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
- quantum_info,quantum_types[i],pixels,exception);
- if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
+ }
+ for (y=0; y < (ssize_t) image->extract_info.height; y++)
+ {
+ register const Quantum
+ *restrict p;
+
+ register Quantum
+ *restrict q;
+
+ register ssize_t
+ x;
+
+ if (count != (ssize_t) length)
+ {
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
break;
- if (((y-image->extract_info.y) >= 0) &&
- ((y-image->extract_info.y) < (ssize_t) image->rows))
+ }
+ q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
+ exception);
+ if (q == (Quantum *) NULL)
+ break;
+ length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
+ quantum_info,BlueQuantum,pixels,exception);
+ if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
+ break;
+ if (((y-image->extract_info.y) >= 0) &&
+ ((y-image->extract_info.y) < (ssize_t) image->rows))
+ {
+ p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
+ canvas_image->columns,1,exception);
+ q=GetAuthenticPixels(image,0,y-image->extract_info.y,
+ image->columns,1,exception);
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
+ break;
+ for (x=0; x < (ssize_t) image->columns; x++)
{
- p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
- canvas_image->columns,1,exception);
- q=GetAuthenticPixels(image,0,y-image->extract_info.y,
- image->columns,1,exception);
- if ((p == (const PixelPacket *) NULL) ||
- (q == (PixelPacket *) NULL))
+ SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
+ p+=GetPixelChannels(canvas_image);
+ q+=GetPixelChannels(image);
+ }
+ if (SyncAuthenticPixels(image,exception) == MagickFalse)
+ break;
+ }
+ count=ReadBlob(image,length,pixels);
+ }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,LoadImageTag,3,6);
+ if (status == MagickFalse)
+ break;
+ }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,LoadImageTag,4,6);
+ if (status == MagickFalse)
+ break;
+ }
+ if (image->alpha_trait == BlendPixelTrait)
+ {
+ for (y=0; y < (ssize_t) image->extract_info.height; y++)
+ {
+ register const Quantum
+ *restrict p;
+
+ register Quantum
+ *restrict q;
+
+ register ssize_t
+ x;
+
+ if (count != (ssize_t) length)
+ {
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
break;
- for (x=0; x < (ssize_t) image->columns; x++)
+ }
+ q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
+ exception);
+ if (q == (Quantum *) NULL)
+ break;
+ length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
+ quantum_info,AlphaQuantum,pixels,exception);
+ if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
+ break;
+ if (((y-image->extract_info.y) >= 0) &&
+ ((y-image->extract_info.y) < (ssize_t) image->rows))
{
- switch(quantum_types[i])
+ p=GetVirtualPixels(canvas_image,
+ canvas_image->extract_info.x,0,canvas_image->columns,1,
+ exception);
+ q=GetAuthenticPixels(image,0,y-image->extract_info.y,
+ image->columns,1,exception);
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
+ break;
+ for (x=0; x < (ssize_t) image->columns; x++)
{
- case RedQuantum: SetRedPixelComponent(q,GetRedPixelComponent(p)); break;
- case GreenQuantum: SetGreenPixelComponent(q,GetGreenPixelComponent(p)); break;
- case BlueQuantum: SetBluePixelComponent(q,GetBluePixelComponent(p)); break;
- case OpacityQuantum:
- case AlphaQuantum: SetOpacityPixelComponent(q,GetOpacityPixelComponent(p)); break;
- default: break;
+ SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
+ p+=GetPixelChannels(canvas_image);
+ q+=GetPixelChannels(image);
}
- p++;
- q++;
+ if (SyncAuthenticPixels(image,exception) == MagickFalse)
+ break;
}
- if (SyncAuthenticPixels(image,exception) == MagickFalse)
+ count=ReadBlob(image,length,pixels);
+ }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,LoadImageTag,5,6);
+ if (status == MagickFalse)
break;
}
- count=ReadBlob(image,length,pixels);
}
- if (image->previous == (Image *) NULL)
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,LoadImageTag,6,6);
+ if (status == MagickFalse)
+ break;
+ }
+ break;
+ }
+ case PartitionInterlace:
+ {
+ /*
+ Partition interlacing: RRRRRR..., GGGGGG..., BBBBBB...
+ */
+ AppendImageFormat("R",image->filename);
+ status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
+ if (status == MagickFalse)
+ {
+ canvas_image=DestroyImageList(canvas_image);
+ image=DestroyImageList(image);
+ return((Image *) NULL);
+ }
+ if (DiscardBlobBytes(image,image->offset) == MagickFalse)
+ ThrowFileException(exception,CorruptImageError,"UnexpectedEndOfFile",
+ image->filename);
+ length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
+ for (i=0; i < (ssize_t) scene; i++)
+ for (y=0; y < (ssize_t) image->extract_info.height; y++)
+ if (ReadBlob(image,length,pixels) != (ssize_t) length)
+ {
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
+ break;
+ }
+ count=ReadBlob(image,length,pixels);
+ for (y=0; y < (ssize_t) image->extract_info.height; y++)
+ {
+ register const Quantum
+ *restrict p;
+
+ register Quantum
+ *restrict q;
+
+ register ssize_t
+ x;
+
+ if (count != (ssize_t) length)
{
- status=SetImageProgress(image,LoadImageTag,(i+1),5);
- if (status == MagickFalse)
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
+ break;
+ }
+ q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
+ exception);
+ if (q == (Quantum *) NULL)
+ break;
+ length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
+ quantum_info,RedQuantum,pixels,exception);
+ if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
+ break;
+ if (((y-image->extract_info.y) >= 0) &&
+ ((y-image->extract_info.y) < (ssize_t) image->rows))
+ {
+ p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
+ canvas_image->columns,1,exception);
+ q=GetAuthenticPixels(image,0,y-image->extract_info.y,
+ image->columns,1,exception);
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
+ break;
+ for (x=0; x < (ssize_t) image->columns; x++)
+ {
+ SetPixelRed(image,GetPixelRed(canvas_image,p),q);
+ p+=GetPixelChannels(canvas_image);
+ q+=GetPixelChannels(image);
+ }
+ if (SyncAuthenticPixels(image,exception) == MagickFalse)
+ break;
+ }
+ count=ReadBlob(image,length,pixels);
+ }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,LoadImageTag,1,5);
+ if (status == MagickFalse)
+ break;
+ }
+ (void) CloseBlob(image);
+ AppendImageFormat("G",image->filename);
+ status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
+ if (status == MagickFalse)
+ {
+ canvas_image=DestroyImageList(canvas_image);
+ image=DestroyImageList(image);
+ return((Image *) NULL);
+ }
+ length=GetQuantumExtent(canvas_image,quantum_info,GreenQuantum);
+ for (i=0; i < (ssize_t) scene; i++)
+ for (y=0; y < (ssize_t) image->extract_info.height; y++)
+ if (ReadBlob(image,length,pixels) != (ssize_t) length)
+ {
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
+ break;
+ }
+ count=ReadBlob(image,length,pixels);
+ for (y=0; y < (ssize_t) image->extract_info.height; y++)
+ {
+ register const Quantum
+ *restrict p;
+
+ register Quantum
+ *restrict q;
+
+ register ssize_t
+ x;
+
+ if (count != (ssize_t) length)
+ {
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
+ break;
+ }
+ q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
+ exception);
+ if (q == (Quantum *) NULL)
+ break;
+ length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
+ quantum_info,GreenQuantum,pixels,exception);
+ if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
+ break;
+ if (((y-image->extract_info.y) >= 0) &&
+ ((y-image->extract_info.y) < (ssize_t) image->rows))
+ {
+ p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
+ canvas_image->columns,1,exception);
+ q=GetAuthenticPixels(image,0,y-image->extract_info.y,
+ image->columns,1,exception);
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
+ break;
+ for (x=0; x < (ssize_t) image->columns; x++)
+ {
+ SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
+ p+=GetPixelChannels(canvas_image);
+ q+=GetPixelChannels(image);
+ }
+ if (SyncAuthenticPixels(image,exception) == MagickFalse)
+ break;
+ }
+ count=ReadBlob(image,length,pixels);
+ }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,LoadImageTag,2,5);
+ if (status == MagickFalse)
+ break;
+ }
+ (void) CloseBlob(image);
+ AppendImageFormat("B",image->filename);
+ status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
+ if (status == MagickFalse)
+ {
+ canvas_image=DestroyImageList(canvas_image);
+ image=DestroyImageList(image);
+ return((Image *) NULL);
+ }
+ length=GetQuantumExtent(canvas_image,quantum_info,BlueQuantum);
+ for (i=0; i < (ssize_t) scene; i++)
+ for (y=0; y < (ssize_t) image->extract_info.height; y++)
+ if (ReadBlob(image,length,pixels) != (ssize_t) length)
+ {
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
+ break;
+ }
+ count=ReadBlob(image,length,pixels);
+ for (y=0; y < (ssize_t) image->extract_info.height; y++)
+ {
+ register const Quantum
+ *restrict p;
+
+ register Quantum
+ *restrict q;
+
+ register ssize_t
+ x;
+
+ if (count != (ssize_t) length)
+ {
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
+ break;
+ }
+ q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
+ exception);
+ if (q == (Quantum *) NULL)
+ break;
+ length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
+ quantum_info,BlueQuantum,pixels,exception);
+ if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
+ break;
+ if (((y-image->extract_info.y) >= 0) &&
+ ((y-image->extract_info.y) < (ssize_t) image->rows))
+ {
+ p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
+ canvas_image->columns,1,exception);
+ q=GetAuthenticPixels(image,0,y-image->extract_info.y,
+ image->columns,1,exception);
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
+ break;
+ for (x=0; x < (ssize_t) image->columns; x++)
+ {
+ SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
+ p+=GetPixelChannels(canvas_image);
+ q+=GetPixelChannels(image);
+ }
+ if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
- }
+ }
+ count=ReadBlob(image,length,pixels);
}
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,LoadImageTag,5,5);
+ status=SetImageProgress(image,LoadImageTag,3,5);
if (status == MagickFalse)
break;
}
- break;
- }
- case PartitionInterlace:
- {
- /*
- Partition interlacing: RRRRRR..., GGGGGG..., BBBBBB...
- */
- for (i=0; i < channels; i++)
- {
- sfx[0]=image_info->magick[i];
- AppendImageFormat(sfx,image->filename);
- status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
- if (status == MagickFalse)
- {
- canvas_image=DestroyImageList(canvas_image);
- image=DestroyImageList(image);
- return((Image *) NULL);
- }
- if (i == 0)
- for (j=0; j < image->offset; j++)
- if (ReadBlobByte(image) == EOF)
- {
- ThrowFileException(exception,CorruptImageError,
- "UnexpectedEndOfFile",image->filename);
- break;
- }
- length=GetQuantumExtent(canvas_image,quantum_info,quantum_types[i]);
- for (j=0; j < (ssize_t) scene; j++)
+ if (image->alpha_trait == BlendPixelTrait)
+ {
+ (void) CloseBlob(image);
+ AppendImageFormat("A",image->filename);
+ status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
+ if (status == MagickFalse)
+ {
+ canvas_image=DestroyImageList(canvas_image);
+ image=DestroyImageList(image);
+ return((Image *) NULL);
+ }
+ length=GetQuantumExtent(canvas_image,quantum_info,AlphaQuantum);
+ for (i=0; i < (ssize_t) scene; i++)
+ for (y=0; y < (ssize_t) image->extract_info.height; y++)
+ if (ReadBlob(image,length,pixels) != (ssize_t) length)
+ {
+ ThrowFileException(exception,CorruptImageError,
+ "UnexpectedEndOfFile",image->filename);
+ break;
+ }
+ count=ReadBlob(image,length,pixels);
for (y=0; y < (ssize_t) image->extract_info.height; y++)
- if (ReadBlob(image,length,pixels) != (ssize_t) length)
+ {
+ register const Quantum
+ *restrict p;
+
+ register Quantum
+ *restrict q;
+
+ register ssize_t
+ x;
+
+ if (count != (ssize_t) length)
{
ThrowFileException(exception,CorruptImageError,
"UnexpectedEndOfFile",image->filename);
break;
}
- count=ReadBlob(image,length,pixels);
- for (y=0; y < (ssize_t) image->extract_info.height; y++)
- {
- register const PixelPacket
- *restrict p;
-
- register ssize_t
- x;
-
- register PixelPacket
- *restrict q;
-
- if (count != (ssize_t) length)
- {
- ThrowFileException(exception,CorruptImageError,
- "UnexpectedEndOfFile",image->filename);
+ q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
+ exception);
+ if (q == (Quantum *) NULL)
break;
- }
- q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
- exception);
- if (q == (PixelPacket *) NULL)
- break;
- length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
- quantum_info,quantum_types[i],pixels,exception);
- if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
- break;
- if (((y-image->extract_info.y) >= 0) &&
- ((y-image->extract_info.y) < (ssize_t) image->rows))
- {
- p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,0,
- canvas_image->columns,1,exception);
- q=GetAuthenticPixels(image,0,y-image->extract_info.y,
- image->columns,1,exception);
- if ((p == (const PixelPacket *) NULL) ||
- (q == (PixelPacket *) NULL))
- break;
- for (x=0; x < (ssize_t) image->columns; x++)
+ length=ImportQuantumPixels(canvas_image,(CacheView *) NULL,
+ quantum_info,BlueQuantum,pixels,exception);
+ if (SyncAuthenticPixels(canvas_image,exception) == MagickFalse)
+ break;
+ if (((y-image->extract_info.y) >= 0) &&
+ ((y-image->extract_info.y) < (ssize_t) image->rows))
{
- switch(quantum_types[i])
+ p=GetVirtualPixels(canvas_image,canvas_image->extract_info.x,
+ 0,canvas_image->columns,1,exception);
+ q=GetAuthenticPixels(image,0,y-image->extract_info.y,
+ image->columns,1,exception);
+ if ((p == (const Quantum *) NULL) || (q == (Quantum *) NULL))
+ break;
+ for (x=0; x < (ssize_t) image->columns; x++)
{
- case RedQuantum: SetRedPixelComponent(q,GetRedPixelComponent(p)); break;
- case GreenQuantum: SetGreenPixelComponent(q,GetGreenPixelComponent(p)); break;
- case BlueQuantum: SetBluePixelComponent(q,GetBluePixelComponent(p)); break;
- case OpacityQuantum:
- case AlphaQuantum: SetOpacityPixelComponent(q,GetOpacityPixelComponent(p)); break;
- default: break;
+ SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
+ p+=GetPixelChannels(canvas_image);
+ q+=GetPixelChannels(image);
}
- p++;
- q++;
- }
- if (SyncAuthenticPixels(image,exception) == MagickFalse)
+ if (SyncAuthenticPixels(image,exception) == MagickFalse)
+ break;
+ }
+ count=ReadBlob(image,length,pixels);
+ }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,LoadImageTag,4,5);
+ if (status == MagickFalse)
break;
}
- count=ReadBlob(image,length,pixels);
}
- if (image->previous == (Image *) NULL)
- {
- status=SetImageProgress(image,LoadImageTag,(i+1),5);
- if (status == MagickFalse)
- break;
- }
- if (i != (channels-1))
- (void) CloseBlob(image);
- }
+ (void) CloseBlob(image);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,5,5);
/*
Allocate next image structure.
*/
- AcquireNextImage(image_info,image);
+ AcquireNextImage(image_info,image,exception);
if (GetNextImageInList(image) == (Image *) NULL)
{
image=DestroyImageList(image);
scene++;
} while (count == (ssize_t) length);
quantum_info=DestroyQuantumInfo(quantum_info);
- InheritException(&image->exception,&canvas_image->exception);
canvas_image=DestroyImage(canvas_image);
(void) CloseBlob(image);
return(GetFirstImageInList(image));
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% RegisterRGBImage() adds attributes for the RGB or RGBA image format to
+% RegisterRGBImage() adds attributes for the RGB image format to
% the list of supported formats. The attributes include the image format
% tag, a method to read and/or write the format, whether the format
% supports the saving of more than one frame to the same file or blob,
entry->description=ConstantString("Raw red, green, and blue samples");
entry->module=ConstantString("RGB");
(void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("RBG");
- entry->decoder=(DecodeImageHandler *) ReadRGBImage;
- entry->encoder=(EncodeImageHandler *) WriteRGBImage;
- entry->raw=MagickTrue;
- entry->endian_support=MagickTrue;
- entry->description=ConstantString("Raw red, blue, and green samples");
- entry->module=ConstantString("RGB");
- (void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("GRB");
- entry->decoder=(DecodeImageHandler *) ReadRGBImage;
- entry->encoder=(EncodeImageHandler *) WriteRGBImage;
- entry->raw=MagickTrue;
- entry->endian_support=MagickTrue;
- entry->description=ConstantString("Raw green, red, and blue samples");
- entry->module=ConstantString("RGB");
- (void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("GBR");
- entry->decoder=(DecodeImageHandler *) ReadRGBImage;
- entry->encoder=(EncodeImageHandler *) WriteRGBImage;
- entry->raw=MagickTrue;
- entry->endian_support=MagickTrue;
- entry->description=ConstantString("Raw green, blue, and red samples");
- entry->module=ConstantString("RGB");
- (void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("BRG");
- entry->decoder=(DecodeImageHandler *) ReadRGBImage;
- entry->encoder=(EncodeImageHandler *) WriteRGBImage;
- entry->raw=MagickTrue;
- entry->endian_support=MagickTrue;
- entry->description=ConstantString("Raw blue, red, and green samples");
- entry->module=ConstantString("RGB");
- (void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("BGR");
- entry->decoder=(DecodeImageHandler *) ReadRGBImage;
- entry->encoder=(EncodeImageHandler *) WriteRGBImage;
- entry->raw=MagickTrue;
- entry->endian_support=MagickTrue;
- entry->description=ConstantString("Raw blue, green, and red samples");
- entry->module=ConstantString("RGB");
- (void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("BGRA");
- entry->decoder=(DecodeImageHandler *) ReadRGBImage;
- entry->encoder=(EncodeImageHandler *) WriteRGBImage;
- entry->raw=MagickTrue;
- entry->endian_support=MagickTrue;
- entry->description=ConstantString("Raw blue, green, red and alpha samples");
- entry->module=ConstantString("RGB");
- (void) RegisterMagickInfo(entry);
entry=SetMagickInfo("RGBA");
entry->decoder=(DecodeImageHandler *) ReadRGBImage;
entry->encoder=(EncodeImageHandler *) WriteRGBImage;
entry->encoder=(EncodeImageHandler *) WriteRGBImage;
entry->raw=MagickTrue;
entry->endian_support=MagickTrue;
- entry->description=ConstantString("Raw red, green, blue, and opacity "
- "samples");
+ entry->description=ConstantString("Raw red, green, blue, and opacity samples");
entry->module=ConstantString("RGB");
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% UnregisterRGBImage() removes format registrations made by the
-% RGB module from the list of supported formats.
+% UnregisterRGBImage() removes format registrations made by the RGB module
+% from the list of supported formats.
%
% The format of the UnregisterRGBImage method is:
%
{
(void) UnregisterMagickInfo("RGBO");
(void) UnregisterMagickInfo("RGBA");
- (void) UnregisterMagickInfo("BGR");
- (void) UnregisterMagickInfo("BGRA");
- (void) UnregisterMagickInfo("BRG");
- (void) UnregisterMagickInfo("GBR");
- (void) UnregisterMagickInfo("GRB");
- (void) UnregisterMagickInfo("RBG");
(void) UnregisterMagickInfo("RGB");
}
\f
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% WriteRGBImage() writes an image to a file in the RGB or RGBA rasterfile
-% format.
+% WriteRGBImage() writes an image to a file in the RGB, RGBA, or RGBO
+% rasterfile format.
%
% The format of the WriteRGBImage method is:
%
-% MagickBooleanType WriteRGBImage(const ImageInfo *image_info,Image *image)
+% MagickBooleanType WriteRGBImage(const ImageInfo *image_info,
+% 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 MagickBooleanType WriteRGBImage(const ImageInfo *image_info,Image *image)
+static MagickBooleanType WriteRGBImage(const ImageInfo *image_info,
+ Image *image,ExceptionInfo *exception)
{
- ssize_t
- y;
-
MagickBooleanType
status;
*quantum_info;
QuantumType
- quantum_type,
- quantum_types[4];
-
- register ssize_t
- i;
-
- ssize_t
- count;
+ quantum_type;
size_t
length;
+ ssize_t
+ count,
+ y;
+
unsigned char
*pixels;
- size_t
- channels;
-
/*
Allocate memory for pixels.
*/
/*
Open output image file.
*/
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
}
quantum_type=RGBQuantum;
- channels=3;
if (LocaleCompare(image_info->magick,"RGBA") == 0)
- {
- quantum_type=RGBAQuantum;
- image->matte=MagickTrue;
- channels=4;
- }
+ quantum_type=RGBAQuantum;
if (LocaleCompare(image_info->magick,"RGBO") == 0)
- {
- quantum_type=RGBOQuantum;
- image->matte=MagickTrue;
- channels=4;
- }
- for (i=0; i < (ssize_t) channels; i++)
- {
- switch (image_info->magick[i])
- {
- case 'R': quantum_types[i]=RedQuantum; break;
- case 'G': quantum_types[i]=GreenQuantum; break;
- case 'B': quantum_types[i]=BlueQuantum; break;
- case 'A': quantum_types[i]=AlphaQuantum; break;
- case 'O': quantum_types[i]=OpacityQuantum; break;
- }
- }
+ quantum_type=RGBOQuantum;
scene=0;
do
{
/*
Convert MIFF to RGB raster pixels.
*/
- if (image->colorspace != RGBColorspace)
- (void) TransformImageColorspace(image,RGBColorspace);
+ if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
if ((LocaleCompare(image_info->magick,"RGBA") == 0) &&
- (image->matte == MagickFalse))
- (void) SetImageAlphaChannel(image,ResetAlphaChannel);
+ (image->alpha_trait != BlendPixelTrait))
+ (void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
quantum_info=AcquireQuantumInfo(image_info,image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
case NoInterlace:
default:
{
- CacheView
- *image_view;
-
- PixelPacket
- px;
-
- Quantum
- *qx[3];
-
/*
No interlacing: RGBRGBRGBRGBRGBRGB...
*/
- image_view=AcquireCacheView(image);
for (y=0; y < (ssize_t) image->rows; y++)
{
- register ssize_t
- x;
-
- register PixelPacket
- *restrict q;
+ register const Quantum
+ *restrict p;
- q=GetCacheViewAuthenticPixels(image_view,0,y,image->columns,1,
- &image->exception);
- if (q == (PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- for (x=0; x < (ssize_t) image->columns; x++)
- {
- px=(*q);
- qx[0]=&(q->red);
- qx[1]=&(q->green);
- qx[2]=&(q->blue);
- for (i=0; i < 3; i++)
- switch (quantum_types[i])
- {
- case RedQuantum: *qx[i]=px.red; break;
- case GreenQuantum: *qx[i]=px.green; break;
- case BlueQuantum: *qx[i]=px.blue; break;
- default: break;
- }
- q++;
- }
- length=ExportQuantumPixels(image,image_view,quantum_info,quantum_type,
- pixels,&image->exception);
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ quantum_type,pixels,exception);
count=WriteBlob(image,length,pixels);
if (count != (ssize_t) length)
break;
break;
}
}
- image_view=DestroyCacheView(image_view);
break;
}
case LineInterlace:
*/
for (y=0; y < (ssize_t) image->rows; y++)
{
- register const PixelPacket
+ register const Quantum
*restrict p;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
- for (i=0; i < (ssize_t) channels; i++)
- {
- length=ExportQuantumPixels(image,(const CacheView *) NULL,
- quantum_info,quantum_types[i],pixels,&image->exception);
- count=WriteBlob(image,length,pixels);
- if (count != (ssize_t) length)
- break;
- }
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ RedQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ GreenQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ BlueQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
+ if (quantum_type == RGBAQuantum)
+ {
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ AlphaQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
+ }
+ if (quantum_type == RGBOQuantum)
+ {
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ OpacityQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
+ }
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
/*
Plane interlacing: RRRRRR...GGGGGG...BBBBBB...
*/
- for (i=0; i < (ssize_t) channels; i++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
- for (y=0; y < (ssize_t) image->rows; y++)
+ register const Quantum
+ *restrict p;
+
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
+ break;
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ RedQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
+ }
+ if (image->previous == (Image *) NULL)
{
- register const PixelPacket
- *restrict p;
+ status=SetImageProgress(image,SaveImageTag,1,6);
+ if (status == MagickFalse)
+ break;
+ }
+ for (y=0; y < (ssize_t) image->rows; y++)
+ {
+ register const Quantum
+ *restrict p;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
+ break;
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ GreenQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
+ }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,SaveImageTag,2,6);
+ if (status == MagickFalse)
break;
- length=ExportQuantumPixels(image,(const CacheView *) NULL,
- quantum_info,quantum_types[i],pixels,&image->exception);
- count=WriteBlob(image,length,pixels);
- if (count != (ssize_t) length)
+ }
+ for (y=0; y < (ssize_t) image->rows; y++)
+ {
+ register const Quantum
+ *restrict p;
+
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
+ break;
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ BlueQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
+ }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,SaveImageTag,3,6);
+ if (status == MagickFalse)
break;
}
- if (image->previous == (Image *) NULL)
+ if (quantum_type == RGBAQuantum)
+ {
+ for (y=0; y < (ssize_t) image->rows; y++)
{
- status=SetImageProgress(image,SaveImageTag,(i+1),5);
- if (status == MagickFalse)
+ register const Quantum
+ *restrict p;
+
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
break;
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ AlphaQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
}
- }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,SaveImageTag,5,6);
+ if (status == MagickFalse)
+ break;
+ }
+ }
+ if (image_info->interlace == PartitionInterlace)
+ (void) CopyMagickString(image->filename,image_info->filename,
+ MaxTextExtent);
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,SaveImageTag,5,5);
+ status=SetImageProgress(image,SaveImageTag,6,6);
if (status == MagickFalse)
break;
}
}
case PartitionInterlace:
{
- char
- sfx[] = {0, 0};
-
/*
Partition interlacing: RRRRRR..., GGGGGG..., BBBBBB...
*/
- for (i=0; i < (ssize_t) channels; i++)
+ AppendImageFormat("R",image->filename);
+ status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
+ AppendBinaryBlobMode,exception);
+ if (status == MagickFalse)
+ return(status);
+ for (y=0; y < (ssize_t) image->rows; y++)
{
- sfx[0]=image_info->magick[i];
- AppendImageFormat(sfx,image->filename);
- status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
- AppendBinaryBlobMode,&image->exception);
- if (status == MagickFalse)
- return(status);
- for (y=0; y < (ssize_t) image->rows; y++)
+ register const Quantum
+ *restrict p;
+
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
+ break;
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ RedQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
+ }
+ if (image->previous == (Image *) NULL)
{
- register const PixelPacket
- *restrict p;
+ status=SetImageProgress(image,SaveImageTag,1,6);
+ if (status == MagickFalse)
+ break;
+ }
+ (void) CloseBlob(image);
+ AppendImageFormat("G",image->filename);
+ status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
+ AppendBinaryBlobMode,exception);
+ if (status == MagickFalse)
+ return(status);
+ for (y=0; y < (ssize_t) image->rows; y++)
+ {
+ register const Quantum
+ *restrict p;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
- if (p == (const PixelPacket *) NULL)
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
+ break;
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ GreenQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
+ }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,SaveImageTag,2,6);
+ if (status == MagickFalse)
break;
- length=ExportQuantumPixels(image,(const CacheView *) NULL,
- quantum_info,quantum_types[i],pixels,&image->exception);
- count=WriteBlob(image,length,pixels);
- if (count != (ssize_t) length)
+ }
+ (void) CloseBlob(image);
+ AppendImageFormat("B",image->filename);
+ status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
+ AppendBinaryBlobMode,exception);
+ if (status == MagickFalse)
+ return(status);
+ for (y=0; y < (ssize_t) image->rows; y++)
+ {
+ register const Quantum
+ *restrict p;
+
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
+ break;
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ BlueQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
+ break;
+ }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,SaveImageTag,3,6);
+ if (status == MagickFalse)
break;
}
- if (image->previous == (Image *) NULL)
+ if (quantum_type == RGBAQuantum)
+ {
+ (void) CloseBlob(image);
+ AppendImageFormat("A",image->filename);
+ status=OpenBlob(image_info,image,scene == 0 ? WriteBinaryBlobMode :
+ AppendBinaryBlobMode,exception);
+ if (status == MagickFalse)
+ return(status);
+ for (y=0; y < (ssize_t) image->rows; y++)
{
- status=SetImageProgress(image,SaveImageTag,(i+1),5);
- if (status == MagickFalse)
+ register const Quantum
+ *restrict p;
+
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
+ if (p == (const Quantum *) NULL)
+ break;
+ length=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
+ AlphaQuantum,pixels,exception);
+ count=WriteBlob(image,length,pixels);
+ if (count != (ssize_t) length)
break;
}
- (void) CloseBlob(image);
- }
+ if (image->previous == (Image *) NULL)
+ {
+ status=SetImageProgress(image,SaveImageTag,5,6);
+ if (status == MagickFalse)
+ break;
+ }
+ }
+ (void) CloseBlob(image);
(void) CopyMagickString(image->filename,image_info->filename,
MaxTextExtent);
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,SaveImageTag,5,5);
+ status=SetImageProgress(image,SaveImageTag,6,6);
if (status == MagickFalse)
break;
}