% MagickCore Pixel Stream Methods %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% March 2000 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2014 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/exception-private.h"
#include "MagickCore/geometry.h"
#include "MagickCore/memory_.h"
+#include "MagickCore/memory-private.h"
#include "MagickCore/pixel.h"
#include "MagickCore/pixel-accessor.h"
#include "MagickCore/quantum.h"
%
% The format of the AcquireStreamInfo method is:
%
-% StreamInfo *AcquireStreamInfo(const ImageInfo *image_info)
+% StreamInfo *AcquireStreamInfo(const ImageInfo *image_info,
+% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
% o image_info: the image info.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
-MagickExport StreamInfo *AcquireStreamInfo(const ImageInfo *image_info)
+MagickExport StreamInfo *AcquireStreamInfo(const ImageInfo *image_info,
+ ExceptionInfo *exception)
{
StreamInfo
*stream_info;
if (stream_info == (StreamInfo *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
(void) ResetMagickMemory(stream_info,0,sizeof(*stream_info));
- stream_info->pixels=(unsigned char *) AcquireMagickMemory(
- sizeof(*stream_info->pixels));
+ stream_info->pixels=(unsigned char *) MagickAssumeAligned(
+ AcquireAlignedMemory(1,sizeof(*stream_info->pixels)));
if (stream_info->pixels == (unsigned char *) NULL)
ThrowFatalException(ResourceLimitFatalError,"MemoryAllocationFailed");
stream_info->map=ConstantString("RGB");
stream_info->storage_type=CharPixel;
- stream_info->stream=AcquireImage(image_info);
+ stream_info->stream=AcquireImage(image_info,exception);
stream_info->signature=MagickSignature;
return(stream_info);
}
{
assert(cache_info != (CacheInfo *) NULL);
if (cache_info->mapped == MagickFalse)
- (void) RelinquishMagickMemory(cache_info->pixels);
+ (void) RelinquishAlignedMemory(cache_info->pixels);
else
(void) UnmapBlob(cache_info->pixels,(size_t) cache_info->length);
cache_info->pixels=(Quantum *) NULL;
if (cache_info->nexus_info != (NexusInfo **) NULL)
cache_info->nexus_info=DestroyPixelCacheNexus(cache_info->nexus_info,
cache_info->number_threads);
- if (cache_info->disk_semaphore != (SemaphoreInfo *) NULL)
- DestroySemaphoreInfo(&cache_info->disk_semaphore);
+ if (cache_info->file_semaphore != (SemaphoreInfo *) NULL)
+ RelinquishSemaphoreInfo(&cache_info->file_semaphore);
if (cache_info->semaphore != (SemaphoreInfo *) NULL)
- DestroySemaphoreInfo(&cache_info->semaphore);
+ RelinquishSemaphoreInfo(&cache_info->semaphore);
cache_info=(CacheInfo *) RelinquishMagickMemory(cache_info);
}
\f
if (stream_info->map != (char *) NULL)
stream_info->map=DestroyString(stream_info->map);
if (stream_info->pixels != (unsigned char *) NULL)
- stream_info->pixels=(unsigned char *) RelinquishMagickMemory(
+ stream_info->pixels=(unsigned char *) RelinquishAlignedMemory(
stream_info->pixels);
if (stream_info->stream != (Image *) NULL)
{
% The format of the GetOneAuthenticPixelFromStream() method is:
%
% MagickBooleanType GetOneAuthenticPixelFromStream(const Image image,
-% const ssize_t x,const ssize_t y,PixelPacket *pixel,
+% const ssize_t x,const ssize_t y,Quantum *pixel,
% ExceptionInfo *exception)
%
% A description of each parameter follows:
%
*/
static MagickBooleanType GetOneAuthenticPixelFromStream(Image *image,
- const ssize_t x,const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
+ const ssize_t x,const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
{
register Quantum
*q;
+ register ssize_t
+ i;
+
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
- *pixel=image->background_color;
+ (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
q=GetAuthenticPixelsStream(image,x,y,1,1,exception);
if (q != (Quantum *) NULL)
- return(MagickFalse);
- GetPixelPacket(image,q,pixel);
+ {
+ pixel[RedPixelChannel]=ClampToQuantum(image->background_color.red);
+ pixel[GreenPixelChannel]=ClampToQuantum(image->background_color.green);
+ pixel[BluePixelChannel]=ClampToQuantum(image->background_color.blue);
+ pixel[BlackPixelChannel]=ClampToQuantum(image->background_color.black);
+ pixel[AlphaPixelChannel]=ClampToQuantum(image->background_color.alpha);
+ return(MagickFalse);
+ }
+ for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ {
+ PixelChannel channel=GetPixelChannelChannel(image,i);
+ pixel[channel]=q[i];
+ }
return(MagickTrue);
}
\f
%
% MagickBooleanType GetOneVirtualPixelFromStream(const Image image,
% const VirtualPixelMethod virtual_pixel_method,const ssize_t x,
-% const ssize_t y,PixelPacket *pixel,ExceptionInfo *exception)
+% const ssize_t y,Quantum *pixel,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
*/
static MagickBooleanType GetOneVirtualPixelFromStream(const Image *image,
const VirtualPixelMethod virtual_pixel_method,const ssize_t x,const ssize_t y,
- PixelPacket *pixel,ExceptionInfo *exception)
+ Quantum *pixel,ExceptionInfo *exception)
{
const Quantum
- *q;
+ *p;
+
+ register ssize_t
+ i;
assert(image != (Image *) NULL);
assert(image->signature == MagickSignature);
- *pixel=image->background_color;
- q=GetVirtualPixelStream(image,virtual_pixel_method,x,y,1,1,exception);
- if (q != (const Quantum *) NULL)
- return(MagickFalse);
- GetPixelPacket(image,q,pixel);
+ (void) memset(pixel,0,MaxPixelChannels*sizeof(*pixel));
+ p=GetVirtualPixelStream(image,virtual_pixel_method,x,y,1,1,exception);
+ if (p == (const Quantum *) NULL)
+ {
+ pixel[RedPixelChannel]=ClampToQuantum(image->background_color.red);
+ pixel[GreenPixelChannel]=ClampToQuantum(image->background_color.green);
+ pixel[BluePixelChannel]=ClampToQuantum(image->background_color.blue);
+ pixel[BlackPixelChannel]=ClampToQuantum(image->background_color.black);
+ pixel[AlphaPixelChannel]=ClampToQuantum(image->background_color.alpha);
+ return(MagickFalse);
+ }
+ for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
+ {
+ PixelChannel channel=GetPixelChannelChannel(image,i);
+ pixel[channel]=p[i];
+ }
return(MagickTrue);
}
\f
%
% GetStreamInfoClientData() gets the stream info client data.
%
-% The format of the SetStreamInfoClientData method is:
+% The format of the GetStreamInfoClientData method is:
%
% const void *GetStreamInfoClientData(StreamInfo *stream_info)
%
% o stream_info: the stream info.
%
*/
-MagickExport const void *GetStreamInfoClientData(StreamInfo *stream_info)
+MagickPrivate const void *GetStreamInfoClientData(StreamInfo *stream_info)
{
assert(stream_info != (StreamInfo *) NULL);
assert(stream_info->signature == MagickSignature);
% %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
-% GetVirtualMetacontentFromStream() returns the associated pixel
-% channels corresponding with the last call to QueueAuthenticPixelsStream() or
+% GetVirtualMetacontentFromStream() returns the associated pixel channels
+% corresponding with the last call to QueueAuthenticPixelsStream() or
% GetVirtualPixelStream().
%
% The format of the GetVirtualMetacontentFromStream() method is:
% o image: the image.
%
*/
-static const void *GetVirtualMetacontentFromStream(
- const Image *image)
+static const void *GetVirtualMetacontentFromStream(const Image *image)
{
CacheInfo
*cache_info;
if (cache_info->length != (MagickSizeType) ((size_t) cache_info->length))
return(MagickFalse);
cache_info->mapped=MagickFalse;
- cache_info->pixels=(Quantum *) AcquireMagickMemory((size_t)
+ cache_info->pixels=(Quantum *) AcquireAlignedMemory(1,(size_t)
cache_info->length);
if (cache_info->pixels == (Quantum *) NULL)
{
Pixels are stored in a temporary buffer until they are synced to the cache.
*/
number_pixels=(MagickSizeType) columns*rows;
- length=(size_t) number_pixels*cache_info->pixel_channels*sizeof(Quantum);
+ length=(size_t) number_pixels*cache_info->number_channels*sizeof(Quantum);
+ if (cache_info->number_channels == 0)
+ length=number_pixels*sizeof(Quantum);
if (cache_info->metacontent_extent != 0)
length+=number_pixels*cache_info->metacontent_extent;
if (cache_info->pixels == (Quantum *) NULL)
}
}
else
- if (cache_info->length != length)
+ if (cache_info->length < length)
{
RelinquishStreamPixels(cache_info);
cache_info->length=length;
cache_info->metacontent=(void *) NULL;
if (cache_info->metacontent_extent != 0)
cache_info->metacontent=(void *) (cache_info->pixels+number_pixels*
- cache_info->pixel_channels);
+ cache_info->number_channels);
return(cache_info->pixels);
}
\f
CacheInfo
*cache_info;
+ MagickBooleanType
+ status;
+
MagickSizeType
number_pixels;
cache_info->columns=columns;
cache_info->rows=rows;
number_pixels=(MagickSizeType) columns*rows;
- length=(size_t) number_pixels*cache_info->pixel_channels*sizeof(Quantum);
+ length=(size_t) number_pixels*cache_info->number_channels*sizeof(Quantum);
+ if (cache_info->number_channels == 0)
+ length=number_pixels*sizeof(Quantum);
if (cache_info->metacontent_extent != 0)
length+=number_pixels*cache_info->metacontent_extent;
if (cache_info->pixels == (Quantum *) NULL)
{
- cache_info->pixels=(Quantum *) AcquireMagickMemory(length);
- cache_info->length=(MagickSizeType) length;
+ cache_info->length=length;
+ status=AcquireStreamPixels(cache_info,exception);
+ if (status == MagickFalse)
+ {
+ cache_info->length=0;
+ return((Quantum *) NULL);
+ }
}
else
- if (cache_info->length < (MagickSizeType) length)
+ if (cache_info->length < length)
{
- cache_info->pixels=(Quantum *) ResizeMagickMemory(
- cache_info->pixels,length);
- cache_info->length=(MagickSizeType) length;
+ RelinquishStreamPixels(cache_info);
+ cache_info->length=length;
+ status=AcquireStreamPixels(cache_info,exception);
+ if (status == MagickFalse)
+ {
+ cache_info->length=0;
+ return((Quantum *) NULL);
+ }
}
- if (cache_info->pixels == (void *) NULL)
- return((Quantum *) NULL);
cache_info->metacontent=(void *) NULL;
if (cache_info->metacontent_extent != 0)
cache_info->metacontent=(void *) (cache_info->pixels+number_pixels*
- cache_info->pixel_channels);
+ cache_info->number_channels);
return(cache_info->pixels);
}
\f
% o client_data: the client data.
%
*/
-MagickExport void SetStreamInfoClientData(StreamInfo *stream_info,
+MagickPrivate void SetStreamInfoClientData(StreamInfo *stream_info,
const void *client_data)
{
assert(stream_info != (StreamInfo *) NULL);
stream_info=(StreamInfo *) image->client_data;
switch (stream_info->storage_type)
{
- default: packet_size=sizeof(char); break;
- case CharPixel: packet_size=sizeof(char); break;
+ default: packet_size=sizeof(unsigned char); break;
+ case CharPixel: packet_size=sizeof(unsigned char); break;
case DoublePixel: packet_size=sizeof(double); break;
case FloatPixel: packet_size=sizeof(float); break;
- case IntegerPixel: packet_size=sizeof(int); break;
- case LongPixel: packet_size=sizeof(ssize_t); break;
+ case LongPixel: packet_size=sizeof(unsigned int); break;
+ case LongLongPixel: packet_size=sizeof(MagickSizeType); break;
case QuantumPixel: packet_size=sizeof(Quantum); break;
case ShortPixel: packet_size=sizeof(unsigned short); break;
}
/*
Prepare stream for writing.
*/
- stream_info->pixels=(unsigned char *) ResizeQuantumMemory(
- stream_info->pixels,length,sizeof(*stream_info->pixels));
+ (void) RelinquishAlignedMemory(stream_info->pixels);
+ stream_info->pixels=(unsigned char *) AcquireAlignedMemory(1,length);
if (stream_info->pixels == (unsigned char *) NULL)
return(0);
+ (void) ResetMagickMemory(stream_info->pixels,0,length);
stream_info->image=image;
write_info=CloneImageInfo(stream_info->image_info);
(void) SetImageInfo(write_info,1,stream_info->exception);
assert(exception != (ExceptionInfo *) NULL);
read_info=CloneImageInfo(image_info);
stream_info->image_info=image_info;
+ stream_info->quantum_info=AcquireQuantumInfo(image_info,(Image *) NULL);
stream_info->exception=exception;
read_info->client_data=(void *) stream_info;
image=ReadStream(read_info,&WriteStreamImage,exception);
read_info=DestroyImageInfo(read_info);
+ stream_info->quantum_info=DestroyQuantumInfo(stream_info->quantum_info);
stream_info->quantum_info=AcquireQuantumInfo(image_info,image);
if (stream_info->quantum_info == (QuantumInfo *) NULL)
image=DestroyImage(image);
{
p=GetAuthenticPixelQueue(image);
if (p == (const Quantum *) NULL)
- break;
+ break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
*q++=ScaleQuantumToChar(GetPixelBlue(image,p));
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=ScaleQuantumToChar(GetPixelIntensity(image,p));
+ *q++=ScaleQuantumToChar(ClampToQuantum(GetPixelIntensity(image,p)));
p++;
}
break;
}
case IndexQuantum:
{
- *q=ScaleQuantumToChar(GetPixelIntensity(image,p));
+ *q=ScaleQuantumToChar(ClampToQuantum(GetPixelIntensity(image,p)));
break;
}
default:
}
break;
}
- case IntegerPixel:
+ case LongPixel:
{
register unsigned int
*q;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p));
+ *q++=ScaleQuantumToLong(GetPixelBlue(image,p));
+ *q++=ScaleQuantumToLong(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToLong(GetPixelRed(image,p));
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelAlpha(image,p));
+ *q++=ScaleQuantumToLong(GetPixelBlue(image,p));
+ *q++=ScaleQuantumToLong(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToLong(GetPixelRed(image,p));
+ *q++=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p)));
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p));
- *q++=0U;
+ *q++=ScaleQuantumToLong(GetPixelBlue(image,p));
+ *q++=ScaleQuantumToLong(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToLong(GetPixelRed(image,p));
+ *q++=0;
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=(unsigned int) ScaleQuantumToLong(
- GetPixelIntensity(image,p));
+ *q++=ScaleQuantumToLong(ClampToQuantum(GetPixelIntensity(image,p)));
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p));
+ *q++=ScaleQuantumToLong(GetPixelRed(image,p));
+ *q++=ScaleQuantumToLong(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToLong(GetPixelBlue(image,p));
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p));
- *q++=(unsigned int) ScaleQuantumToLong((Quantum)
- (GetPixelAlpha(image,p)));
+ *q++=ScaleQuantumToLong(GetPixelRed(image,p));
+ *q++=ScaleQuantumToLong(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToLong(GetPixelBlue(image,p));
+ *q++=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p)));
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p));
- *q++=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p));
- *q++=0U;
+ *q++=ScaleQuantumToLong(GetPixelRed(image,p));
+ *q++=ScaleQuantumToLong(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToLong(GetPixelBlue(image,p));
+ *q++=0;
p++;
}
break;
case RedQuantum:
case CyanQuantum:
{
- *q=(unsigned int) ScaleQuantumToLong(GetPixelRed(image,p));
+ *q=ScaleQuantumToLong(GetPixelRed(image,p));
break;
}
case GreenQuantum:
case MagentaQuantum:
{
- *q=(unsigned int) ScaleQuantumToLong(GetPixelGreen(image,p));
+ *q=ScaleQuantumToLong(GetPixelGreen(image,p));
break;
}
case BlueQuantum:
case YellowQuantum:
{
- *q=(unsigned int) ScaleQuantumToLong(GetPixelBlue(image,p));
+ *q=ScaleQuantumToLong(GetPixelBlue(image,p));
break;
}
case AlphaQuantum:
{
- *q=(unsigned int) ScaleQuantumToLong(GetPixelAlpha(image,p));
+ *q=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p)));
break;
}
case OpacityQuantum:
{
- *q=(unsigned int) ScaleQuantumToLong(GetPixelAlpha(image,p));
+ *q=ScaleQuantumToLong(GetPixelAlpha(image,p));
break;
}
case BlackQuantum:
{
if (image->colorspace == CMYKColorspace)
- *q=(unsigned int) ScaleQuantumToLong(GetPixelBlack(image,p));
+ *q=ScaleQuantumToLong(GetPixelBlack(image,p));
break;
}
case IndexQuantum:
{
- *q=(unsigned int)
- ScaleQuantumToLong(GetPixelIntensity(image,p));
+ *q=ScaleQuantumToLong(ClampToQuantum(GetPixelIntensity(image,p)));
break;
}
default:
- *q=0;
+ break;
}
q++;
}
}
break;
}
- case LongPixel:
+ case LongLongPixel:
{
- register size_t
+ register MagickSizeType
*q;
- q=(size_t *) stream_info->pixels;
+ q=(MagickSizeType *) stream_info->pixels;
if (LocaleCompare(stream_info->map,"BGR") == 0)
{
p=GetAuthenticPixelQueue(image);
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=ScaleQuantumToLong(GetPixelBlue(image,p));
- *q++=ScaleQuantumToLong(GetPixelGreen(image,p));
- *q++=ScaleQuantumToLong(GetPixelRed(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelRed(image,p));
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=ScaleQuantumToLong(GetPixelBlue(image,p));
- *q++=ScaleQuantumToLong(GetPixelGreen(image,p));
- *q++=ScaleQuantumToLong(GetPixelRed(image,p));
- *q++=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p)));
+ *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelRed(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelAlpha(image,p));
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=ScaleQuantumToLong(GetPixelBlue(image,p));
- *q++=ScaleQuantumToLong(GetPixelGreen(image,p));
- *q++=ScaleQuantumToLong(GetPixelRed(image,p));
- *q++=0;
+ *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelRed(image,p));
+ *q++=0U;
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=ScaleQuantumToLong(GetPixelIntensity(image,p));
+ *q++=ScaleQuantumToLongLong(ClampToQuantum(
+ GetPixelIntensity(image,p)));
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=ScaleQuantumToLong(GetPixelRed(image,p));
- *q++=ScaleQuantumToLong(GetPixelGreen(image,p));
- *q++=ScaleQuantumToLong(GetPixelBlue(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelRed(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p));
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=ScaleQuantumToLong(GetPixelRed(image,p));
- *q++=ScaleQuantumToLong(GetPixelGreen(image,p));
- *q++=ScaleQuantumToLong(GetPixelBlue(image,p));
- *q++=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p)));
+ *q++=ScaleQuantumToLongLong(GetPixelRed(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelAlpha(image,p));
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=ScaleQuantumToLong(GetPixelRed(image,p));
- *q++=ScaleQuantumToLong(GetPixelGreen(image,p));
- *q++=ScaleQuantumToLong(GetPixelBlue(image,p));
- *q++=0;
+ *q++=ScaleQuantumToLongLong(GetPixelRed(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToLongLong(GetPixelBlue(image,p));
+ *q++=0U;
p++;
}
break;
case RedQuantum:
case CyanQuantum:
{
- *q=ScaleQuantumToLong(GetPixelRed(image,p));
+ *q=ScaleQuantumToLongLong(GetPixelRed(image,p));
break;
}
case GreenQuantum:
case MagentaQuantum:
{
- *q=ScaleQuantumToLong(GetPixelGreen(image,p));
+ *q=ScaleQuantumToLongLong(GetPixelGreen(image,p));
break;
}
case BlueQuantum:
case YellowQuantum:
{
- *q=ScaleQuantumToLong(GetPixelBlue(image,p));
+ *q=ScaleQuantumToLongLong(GetPixelBlue(image,p));
break;
}
case AlphaQuantum:
{
- *q=ScaleQuantumToLong((Quantum) (GetPixelAlpha(image,p)));
+ *q=ScaleQuantumToLongLong(GetPixelAlpha(image,p));
break;
}
case OpacityQuantum:
{
- *q=ScaleQuantumToLong(GetPixelAlpha(image,p));
+ *q=ScaleQuantumToLongLong(GetPixelAlpha(image,p));
break;
}
case BlackQuantum:
{
if (image->colorspace == CMYKColorspace)
- *q=ScaleQuantumToLong(GetPixelBlack(image,p));
+ *q=ScaleQuantumToLongLong(GetPixelBlack(image,p));
break;
}
case IndexQuantum:
{
- *q=ScaleQuantumToLong(GetPixelIntensity(image,p));
+ *q=ScaleQuantumToLongLong(ClampToQuantum(
+ GetPixelIntensity(image,p)));
break;
}
default:
- break;
+ *q=0;
}
q++;
}
*q++=GetPixelBlue(image,p);
*q++=GetPixelGreen(image,p);
*q++=GetPixelRed(image,p);
- *q++=(Quantum) (GetPixelAlpha(image,p));
+ *q++=GetPixelAlpha(image,p);
p++;
}
break;
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=GetPixelIntensity(image,p);
+ *q++=ClampToQuantum(GetPixelIntensity(image,p));
p++;
}
break;
*q++=GetPixelRed(image,p);
*q++=GetPixelGreen(image,p);
*q++=GetPixelBlue(image,p);
- *q++=(Quantum) (GetPixelAlpha(image,p));
+ *q++=GetPixelAlpha(image,p);
p++;
}
break;
}
case IndexQuantum:
{
- *q=(GetPixelIntensity(image,p));
+ *q=ClampToQuantum(GetPixelIntensity(image,p));
break;
}
default:
break;
for (x=0; x < (ssize_t) GetImageExtent(image); x++)
{
- *q++=ScaleQuantumToShort(GetPixelIntensity(image,p));
+ *q++=ScaleQuantumToShort(ClampToQuantum(
+ GetPixelIntensity(image,p)));
p++;
}
break;
}
case IndexQuantum:
{
- *q=ScaleQuantumToShort(GetPixelIntensity(image,p));
+ *q=ScaleQuantumToShort(ClampToQuantum(
+ GetPixelIntensity(image,p)));
break;
}
default:
% The format of the WriteStream() method is:
%
% MagickBooleanType WriteStream(const ImageInfo *image_info,Image *,
-% StreamHandler stream)
+% StreamHandler stream,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
%
% o stream: A callback method.
%
+% o exception: return any errors or warnings in this structure.
+%
*/
MagickExport MagickBooleanType WriteStream(const ImageInfo *image_info,
- Image *image,StreamHandler stream)
+ Image *image,StreamHandler stream,ExceptionInfo *exception)
{
ImageInfo
*write_info;
assert(image->signature == MagickSignature);
write_info=CloneImageInfo(image_info);
write_info->stream=stream;
- status=WriteImage(write_info,image);
+ status=WriteImage(write_info,image,exception);
write_info=DestroyImageInfo(write_info);
return(status);
}