% Read/Write Raw BGR Image Format %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% July 1992 %
% %
% %
-% Copyright 1999-2008 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 %
#include "MagickCore/blob.h"
#include "MagickCore/blob-private.h"
#include "MagickCore/cache.h"
+#include "MagickCore/channel.h"
#include "MagickCore/colorspace.h"
#include "MagickCore/colorspace-private.h"
#include "MagickCore/constitute.h"
static Image *ReadBGRImage(const ImageInfo *image_info,
ExceptionInfo *exception)
{
+ const void
+ *pixels;
+
Image
*canvas_image,
*image;
count,
y;
- unsigned char
- *pixels;
-
/*
Open image file.
*/
image=AcquireImage(image_info,exception);
if ((image->columns == 0) || (image->rows == 0))
ThrowReaderException(OptionError,"MustSpecifyImageSize");
- image->colorspace=sRGBColorspace;
if (image_info->interlace != PartitionInterlace)
{
status=OpenBlob(image_info,image,ReadBinaryBlobMode,exception);
quantum_info=AcquireQuantumInfo(image_info,canvas_image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
- pixels=GetQuantumPixels(quantum_info);
quantum_type=BGRQuantum;
if (LocaleCompare(image_info->magick,"BGRA") == 0)
{
quantum_type=BGRAQuantum;
- image->matte=MagickTrue;
+ image->alpha_trait=BlendPixelTrait;
+ canvas_image->alpha_trait=BlendPixelTrait;
}
+ if (LocaleCompare(image_info->magick,"BGRO") == 0)
+ {
+ quantum_type=BGROQuantum;
+ image->alpha_trait=BlendPixelTrait;
+ canvas_image->alpha_trait=BlendPixelTrait;
+ }
+ pixels=(const void *) NULL;
if (image_info->number_scenes != 0)
while (image->scene < image_info->scene)
{
length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
for (y=0; y < (ssize_t) image->rows; y++)
{
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
if (count != (ssize_t) length)
break;
}
if ((image_info->ping != MagickFalse) && (image_info->number_scenes != 0))
if (image->scene >= (image_info->scene+image_info->number_scenes-1))
break;
- image->colorspace=sRGBColorspace;
+ status=SetImageExtent(image,image->columns,image->rows,exception);
+ if (status == MagickFalse)
+ return(DestroyImageList(image));
switch (image_info->interlace)
{
case NoInterlace:
if (scene == 0)
{
length=GetQuantumExtent(canvas_image,quantum_info,quantum_type);
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
for (y=0; y < (ssize_t) image->extract_info.height; y++)
{
SetPixelGreen(image,GetPixelGreen(canvas_image,p),q);
SetPixelBlue(image,GetPixelBlue(canvas_image,p),q);
SetPixelAlpha(image,OpaqueAlpha,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait != UndefinedPixelTrait)
SetPixelAlpha(image,GetPixelAlpha(canvas_image,p),q);
p+=GetPixelChannels(canvas_image);
q+=GetPixelChannels(image);
if (status == MagickFalse)
break;
}
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
break;
}
if (scene == 0)
{
length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
for (y=0; y < (ssize_t) image->extract_info.height; y++)
{
"UnexpectedEndOfFile",image->filename);
break;
}
- for (i=0; i < (ssize_t) (image->matte != MagickFalse ? 4 : 3); i++)
+ for (i=0; i < (ssize_t) (image->alpha_trait != UndefinedPixelTrait ? 4 : 3); i++)
{
quantum_type=quantum_types[i];
q=GetAuthenticPixels(canvas_image,0,0,canvas_image->columns,1,
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
if (image->previous == (Image *) NULL)
{
if (scene == 0)
{
length=GetQuantumExtent(canvas_image,quantum_info,RedQuantum);
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
for (y=0; y < (ssize_t) image->extract_info.height; y++)
{
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
if (image->previous == (Image *) NULL)
{
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
if (image->previous == (Image *) NULL)
{
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
if (image->previous == (Image *) NULL)
{
if (status == MagickFalse)
break;
}
- if (image->matte != MagickFalse)
+ if (image->alpha_trait != UndefinedPixelTrait)
{
for (y=0; y < (ssize_t) image->extract_info.height; y++)
{
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
if (image->previous == (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)
+ {
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
+ if (count != (ssize_t) length)
{
ThrowFileException(exception,CorruptImageError,
"UnexpectedEndOfFile",image->filename);
break;
}
- count=ReadBlob(image,length,pixels);
+ }
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
for (y=0; y < (ssize_t) image->extract_info.height; y++)
{
register const Quantum
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
if (image->previous == (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)
+ {
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
+ if (count != (ssize_t) length)
{
ThrowFileException(exception,CorruptImageError,
"UnexpectedEndOfFile",image->filename);
break;
}
- count=ReadBlob(image,length,pixels);
+ }
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
for (y=0; y < (ssize_t) image->extract_info.height; y++)
{
register const Quantum
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
if (image->previous == (Image *) NULL)
{
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)
+ {
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
+ if (count != (ssize_t) length)
{
ThrowFileException(exception,CorruptImageError,
"UnexpectedEndOfFile",image->filename);
break;
}
- count=ReadBlob(image,length,pixels);
+ }
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
for (y=0; y < (ssize_t) image->extract_info.height; y++)
{
register const Quantum
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
if (image->previous == (Image *) NULL)
{
if (status == MagickFalse)
break;
}
- if (image->matte != MagickFalse)
+ if (image->alpha_trait != UndefinedPixelTrait)
{
(void) CloseBlob(image);
AppendImageFormat("A",image->filename);
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)
+ {
+ pixels=ReadBlobStream(image,length,
+ GetQuantumPixels(quantum_info),&count);
+ if (count != (ssize_t) length)
{
ThrowFileException(exception,CorruptImageError,
"UnexpectedEndOfFile",image->filename);
break;
}
- count=ReadBlob(image,length,pixels);
+ }
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
for (y=0; y < (ssize_t) image->extract_info.height; y++)
{
register const Quantum
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
}
- count=ReadBlob(image,length,pixels);
+ pixels=ReadBlobStream(image,length,GetQuantumPixels(quantum_info),
+ &count);
}
if (image->previous == (Image *) NULL)
{
MagickInfo
*entry;
- entry=SetMagickInfo("BGR");
+ entry=AcquireMagickInfo("BGR","BGR","Raw blue, green, and red samples");
+ entry->decoder=(DecodeImageHandler *) ReadBGRImage;
+ entry->encoder=(EncodeImageHandler *) WriteBGRImage;
+ entry->flags|=CoderRawSupportFlag;
+ entry->flags|=CoderEndianSupportFlag;
+ (void) RegisterMagickInfo(entry);
+ entry=AcquireMagickInfo("BGR","BGRA",
+ "Raw blue, green, red, and alpha samples");
entry->decoder=(DecodeImageHandler *) ReadBGRImage;
entry->encoder=(EncodeImageHandler *) WriteBGRImage;
- entry->raw=MagickTrue;
- entry->endian_support=MagickTrue;
- entry->description=ConstantString("Raw blue, green, and red samples");
- entry->module=ConstantString("BGR");
+ entry->flags|=CoderRawSupportFlag;
+ entry->flags|=CoderEndianSupportFlag;
(void) RegisterMagickInfo(entry);
- entry=SetMagickInfo("BGRA");
+ entry=AcquireMagickInfo("BGR","BGRO",
+ "Raw blue, green, red, and opacity samples");
entry->decoder=(DecodeImageHandler *) ReadBGRImage;
entry->encoder=(EncodeImageHandler *) WriteBGRImage;
- entry->raw=MagickTrue;
- entry->endian_support=MagickTrue;
- entry->description=ConstantString("Raw blue, green, red, and alpha samples");
- entry->module=ConstantString("BGR");
+ entry->flags|=CoderRawSupportFlag;
+ entry->flags|=CoderEndianSupportFlag;
(void) RegisterMagickInfo(entry);
return(MagickImageCoderSignature);
}
if (LocaleCompare(image_info->magick,"BGRA") == 0)
{
quantum_type=BGRAQuantum;
- image->matte=MagickTrue;
+ image->alpha_trait=BlendPixelTrait;
}
scene=0;
do
/*
Convert MIFF to BGR raster pixels.
*/
- if (IssRGBColorspace(image->colorspace) == MagickFalse)
- (void) TransformImageColorspace(image,sRGBColorspace,exception);
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
if ((LocaleCompare(image_info->magick,"BGRA") == 0) &&
- (image->matte == MagickFalse))
+ (image->alpha_trait == UndefinedPixelTrait))
(void) SetImageAlphaChannel(image,OpaqueAlphaChannel,exception);
quantum_info=AcquireQuantumInfo(image_info,image);
if (quantum_info == (QuantumInfo *) NULL)
}
if (image_info->interlace == PartitionInterlace)
(void) CopyMagickString(image->filename,image_info->filename,
- MaxTextExtent);
+ MagickPathExtent);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,6,6);
}
(void) CloseBlob(image);
(void) CopyMagickString(image->filename,image_info->filename,
- MaxTextExtent);
+ MagickPathExtent);
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,SaveImageTag,6,6);