% MagickCore Methods to Import Quantum Pixels %
% %
% Software Design %
-% John Cristy %
+% Cristy %
% October 1998 %
% %
% %
-% Copyright 1999-2008 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 %
%
% size_t ImportQuantumPixels(const Image *image,CacheView *image_view,
% QuantumInfo *quantum_info,const QuantumType quantum_type,
-% const unsigned char *pixels,ExceptionInfo *exception)
+% const unsigned char *restrict pixels,ExceptionInfo *exception)
%
% A description of each parameter follows:
%
}
static inline const unsigned char *PushDoublePixel(QuantumInfo *quantum_info,
- const unsigned char *pixels,double *pixel)
+ const unsigned char *restrict pixels,double *pixel)
{
double
*p;
unsigned char
quantum[8];
- if (quantum_info->endian != LSBEndian)
+ if (quantum_info->endian == LSBEndian)
{
- quantum[7]=(*pixels++);
- quantum[6]=(*pixels++);
- quantum[5]=(*pixels++);
- quantum[5]=(*pixels++);
- quantum[3]=(*pixels++);
- quantum[2]=(*pixels++);
- quantum[1]=(*pixels++);
quantum[0]=(*pixels++);
+ quantum[1]=(*pixels++);
+ quantum[2]=(*pixels++);
+ quantum[3]=(*pixels++);
+ quantum[4]=(*pixels++);
+ quantum[5]=(*pixels++);
+ quantum[6]=(*pixels++);
+ quantum[7]=(*pixels++);
p=(double *) quantum;
*pixel=(*p);
*pixel-=quantum_info->minimum;
*pixel*=quantum_info->scale;
return(pixels);
}
- quantum[0]=(*pixels++);
- quantum[1]=(*pixels++);
- quantum[2]=(*pixels++);
- quantum[3]=(*pixels++);
- quantum[4]=(*pixels++);
- quantum[5]=(*pixels++);
- quantum[6]=(*pixels++);
quantum[7]=(*pixels++);
+ quantum[6]=(*pixels++);
+ quantum[5]=(*pixels++);
+ quantum[4]=(*pixels++);
+ quantum[3]=(*pixels++);
+ quantum[2]=(*pixels++);
+ quantum[1]=(*pixels++);
+ quantum[0]=(*pixels++);
p=(double *) quantum;
*pixel=(*p);
*pixel-=quantum_info->minimum;
}
static inline const unsigned char *PushFloatPixel(QuantumInfo *quantum_info,
- const unsigned char *pixels,float *pixel)
+ const unsigned char *restrict pixels,float *pixel)
{
float
*p;
unsigned char
quantum[4];
- if (quantum_info->endian != LSBEndian)
+ if (quantum_info->endian == LSBEndian)
{
- quantum[3]=(*pixels++);
- quantum[2]=(*pixels++);
- quantum[1]=(*pixels++);
quantum[0]=(*pixels++);
+ quantum[1]=(*pixels++);
+ quantum[2]=(*pixels++);
+ quantum[3]=(*pixels++);
p=(float *) quantum;
*pixel=(*p);
*pixel-=quantum_info->minimum;
*pixel*=quantum_info->scale;
return(pixels);
}
- quantum[0]=(*pixels++);
- quantum[1]=(*pixels++);
- quantum[2]=(*pixels++);
quantum[3]=(*pixels++);
+ quantum[2]=(*pixels++);
+ quantum[1]=(*pixels++);
+ quantum[0]=(*pixels++);
p=(float *) quantum;
*pixel=(*p);
*pixel-=quantum_info->minimum;
}
static inline const unsigned char *PushQuantumPixel(QuantumInfo *quantum_info,
- const unsigned char *pixels,unsigned int *quantum)
+ const unsigned char *restrict pixels,unsigned int *quantum)
{
register ssize_t
i;
}
static inline const unsigned char *PushQuantumLongPixel(
- QuantumInfo *quantum_info,const unsigned char *pixels,unsigned int *quantum)
+ QuantumInfo *quantum_info,const unsigned char *restrict pixels,
+ unsigned int *quantum)
{
register ssize_t
i;
unsigned int
pixel;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
switch (quantum_info->depth)
{
case 8:
unsigned int
pixel;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
switch (quantum_info->depth)
{
case 8:
unsigned int
pixel;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
switch (quantum_info->depth)
{
case 8:
if (image->colorspace != CMYKColorspace)
{
(void) ThrowMagickException(exception,GetMagickModule(),ImageError,
- "ColorSeparatedImageRequired","'%s'",image->filename);
+ "ColorSeparatedImageRequired","`%s'",image->filename);
return;
}
switch (quantum_info->depth)
unsigned int
pixel;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
switch (quantum_info->depth)
{
case 8:
unsigned int
pixel;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
switch (quantum_info->depth)
{
case 10:
if (image->colorspace != CMYKColorspace)
{
(void) ThrowMagickException(exception,GetMagickModule(),ImageError,
- "ColorSeparatedImageRequired","'%s'",image->filename);
+ "ColorSeparatedImageRequired","`%s'",image->filename);
return;
}
switch (quantum_info->depth)
if (image->colorspace != CMYKColorspace)
{
(void) ThrowMagickException(exception,GetMagickModule(),ImageError,
- "ColorSeparatedImageRequired","'%s'",image->filename);
+ "ColorSeparatedImageRequired","`%s'",image->filename);
return;
}
switch (quantum_info->depth)
unsigned int
pixel;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
switch (quantum_info->depth)
{
case 1:
range=GetQuantumRange(quantum_info->depth);
if (quantum_info->pack == MagickFalse)
{
- if (image->endian != LSBEndian)
+ if (image->endian == LSBEndian)
{
for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
{
p=PushLongPixel(quantum_info->endian,p,&pixel);
- SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,
+ SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,
range),q);
q+=GetPixelChannels(image);
SetPixelGray(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,
range),q);
q+=GetPixelChannels(image);
- SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,
+ SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,
range),q);
p+=quantum_info->pad;
q+=GetPixelChannels(image);
p=PushLongPixel(quantum_info->endian,p,&pixel);
if (x++ < (ssize_t) (number_pixels-1))
{
- SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,
+ SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,
range),q);
q+=GetPixelChannels(image);
}
for (x=0; x < (ssize_t) (number_pixels-2); x+=3)
{
p=PushLongPixel(quantum_info->endian,p,&pixel);
- SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range),
+ SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range),
q);
q+=GetPixelChannels(image);
SetPixelGray(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range),
q);
q+=GetPixelChannels(image);
- SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,range),
+ SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range),
q);
p+=quantum_info->pad;
q+=GetPixelChannels(image);
p=PushLongPixel(quantum_info->endian,p,&pixel);
if (x++ < (ssize_t) (number_pixels-1))
{
- SetPixelGray(image,ScaleAnyToQuantum((pixel >> 22) & 0x3ff,range),
- q);
+ SetPixelGray(image,ScaleAnyToQuantum((pixel >> 2) & 0x3ff,
+ range),q);
q+=GetPixelChannels(image);
}
if (x++ < (ssize_t) number_pixels)
{
- SetPixelGray(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,range),
- q);
+ SetPixelGray(image,ScaleAnyToQuantum((pixel >> 12) & 0x3ff,
+ range),q);
q+=GetPixelChannels(image);
}
break;
unsigned int
pixel;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
switch (quantum_info->depth)
{
case 1:
register unsigned char
pixel;
+ bit=0;
for (x=((ssize_t) number_pixels-3); x > 0; x-=4)
{
for (bit=0; bit < 8; bit+=2)
unsigned int
pixel;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
switch (quantum_info->depth)
{
case 8:
if (image->storage_class != PseudoClass)
{
(void) ThrowMagickException(exception,GetMagickModule(),ImageError,
- "ColormappedImageRequired","'%s'",image->filename);
+ "ColormappedImageRequired","`%s'",image->filename);
return;
}
range_exception=MagickFalse;
}
if (range_exception != MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
- "InvalidColormapIndex","'%s'",image->filename);
+ "InvalidColormapIndex","`%s'",image->filename);
}
static void ImportIndexAlphaQuantum(const Image *image,
if (image->storage_class != PseudoClass)
{
(void) ThrowMagickException(exception,GetMagickModule(),ImageError,
- "ColormappedImageRequired","'%s'",image->filename);
+ "ColormappedImageRequired","`%s'",image->filename);
return;
}
range_exception=MagickFalse;
}
if (range_exception != MagickFalse)
(void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
- "InvalidColormapIndex","'%s'",image->filename);
+ "InvalidColormapIndex","`%s'",image->filename);
}
static void ImportOpacityQuantum(const Image *image,QuantumInfo *quantum_info,
unsigned int
pixel;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
switch (quantum_info->depth)
{
case 8:
}
}
}
+
static void ImportRedQuantum(const Image *image,QuantumInfo *quantum_info,
const MagickSizeType number_pixels,const unsigned char *restrict p,
Quantum *restrict q,ExceptionInfo *exception)
unsigned int
pixel;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
switch (quantum_info->depth)
{
case 8:
unsigned int
pixel;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
switch (quantum_info->depth)
{
case 8:
unsigned int
pixel;
+ assert(image != (Image *) NULL);
+ assert(image->signature == MagickSignature);
switch (quantum_info->depth)
{
case 8:
MagickExport size_t ImportQuantumPixels(const Image *image,
CacheView *image_view,QuantumInfo *quantum_info,
- const QuantumType quantum_type,const unsigned char *pixels,
+ const QuantumType quantum_type,const unsigned char *restrict pixels,
ExceptionInfo *exception)
{
MagickSizeType
register ssize_t
i;
- if (GetPixelMask(image,q) != 0)
+ if (GetPixelReadMask(image,q) == 0)
{
q+=GetPixelChannels(image);
continue;
gamma=PerceptibleReciprocal(Sa);
for (i=0; i < (ssize_t) GetPixelChannels(image); i++)
{
- PixelChannel
- channel;
-
- PixelTrait
- traits;
-
- channel=GetPixelChannelChannel(image,i);
- traits=GetPixelChannelTraits(image,channel);
+ PixelChannel channel=GetPixelChannelChannel(image,i);
+ PixelTrait traits=GetPixelChannelTraits(image,channel);
if ((traits & UpdatePixelTrait) == 0)
continue;
q[i]=ClampToQuantum(gamma*q[i]);