% July 1992 %
% %
% %
-% Copyright 1999-2011 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 "MagickCore/color.h"
#include "MagickCore/color-private.h"
#include "MagickCore/colorspace.h"
+#include "MagickCore/colorspace-private.h"
#include "MagickCore/exception.h"
#include "MagickCore/exception-private.h"
#include "MagickCore/image.h"
Forward declarations.
*/
static MagickBooleanType
- WritePNMImage(const ImageInfo *,Image *);
+ WritePNMImage(const ImageInfo *,Image *,ExceptionInfo *);
\f
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
static inline ssize_t ConstrainPixel(Image *image,const ssize_t offset,
- const size_t extent)
+ const size_t extent,ExceptionInfo *exception)
{
if ((offset < 0) || (offset > (ssize_t) extent))
{
- (void) ThrowMagickException(&image->exception,GetMagickModule(),
- CorruptImageError,"InvalidPixel","`%s'",image->filename);
+ (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
+ "InvalidPixel","`%s'",image->filename);
return(0);
}
return(offset);
}
-static size_t PNMInteger(Image *image,const unsigned int base)
+static size_t PNMInteger(Image *image,const unsigned int base,
+ ExceptionInfo *exception)
{
char
*comment;
p=comment+strlen(comment);
}
c=ReadBlobByte(image);
- *p=(char) c;
- *(p+1)='\0';
+ if (c != (int) '\n')
+ {
+ *p=(char) c;
+ *(p+1)='\0';
+ }
}
if (comment == (char *) NULL)
return(0);
} while (isdigit(c) == MagickFalse);
if (comment != (char *) NULL)
{
- (void) SetImageProperty(image,"comment",comment);
+ (void) SetImageProperty(image,"comment",comment,exception);
comment=DestroyString(comment);
}
if (base == 2)
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)
{
/*
PBM, PGM, PPM, and PNM.
*/
- image->columns=PNMInteger(image,10);
- image->rows=PNMInteger(image,10);
+ image->columns=PNMInteger(image,10,exception);
+ image->rows=PNMInteger(image,10,exception);
if ((format == 'f') || (format == 'F'))
{
char
scale[MaxTextExtent];
(void) ReadBlobString(image,scale);
- quantum_scale=InterpretLocaleValue(scale,(char **) NULL);
+ quantum_scale=StringToDouble(scale,(char **) NULL);
}
else
{
if ((format == '1') || (format == '4'))
max_value=1; /* bitmap */
else
- max_value=PNMInteger(image,10);
+ max_value=PNMInteger(image,10,exception);
}
}
else
if (LocaleCompare(keyword,"TUPLTYPE") == 0)
{
if (LocaleCompare(value,"BLACKANDWHITE") == 0)
- quantum_type=GrayQuantum;
+ {
+ SetImageColorspace(image,GRAYColorspace,exception);
+ quantum_type=GrayQuantum;
+ }
if (LocaleCompare(value,"BLACKANDWHITE_ALPHA") == 0)
{
+ SetImageColorspace(image,GRAYColorspace,exception);
+ image->alpha_trait=BlendPixelTrait;
quantum_type=GrayAlphaQuantum;
- image->matte=MagickTrue;
}
if (LocaleCompare(value,"GRAYSCALE") == 0)
- quantum_type=GrayQuantum;
+ {
+ quantum_type=GrayQuantum;
+ SetImageColorspace(image,GRAYColorspace,exception);
+ }
if (LocaleCompare(value,"GRAYSCALE_ALPHA") == 0)
{
+ SetImageColorspace(image,GRAYColorspace,exception);
+ image->alpha_trait=BlendPixelTrait;
quantum_type=GrayAlphaQuantum;
- image->matte=MagickTrue;
}
if (LocaleCompare(value,"RGB_ALPHA") == 0)
{
+ image->alpha_trait=BlendPixelTrait;
quantum_type=RGBAQuantum;
- image->matte=MagickTrue;
}
if (LocaleCompare(value,"CMYK") == 0)
{
+ SetImageColorspace(image,CMYKColorspace,exception);
quantum_type=CMYKQuantum;
- image->colorspace=CMYKColorspace;
}
if (LocaleCompare(value,"CMYK_ALPHA") == 0)
{
+ SetImageColorspace(image,CMYKColorspace,exception);
+ image->alpha_trait=BlendPixelTrait;
quantum_type=CMYKAQuantum;
- image->colorspace=CMYKColorspace;
- image->matte=MagickTrue;
}
}
if (LocaleCompare(keyword,"width") == 0)
/*
Convert PBM image to pixel packets.
*/
+ SetImageColorspace(image,GRAYColorspace,exception);
for (y=0; y < (ssize_t) image->rows; y++)
{
register ssize_t
*restrict q;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- SetPixelRed(image,PNMInteger(image,2) == 0 ? QuantumRange : 0,q);
- SetPixelGreen(image,GetPixelRed(image,q),q);
- SetPixelBlue(image,GetPixelRed(image,q),q);
+ SetPixelGray(image,PNMInteger(image,2,exception) == 0 ?
+ QuantumRange : 0,q);
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
/*
Convert PGM image to pixel packets.
*/
+ SetImageColorspace(image,GRAYColorspace,exception);
scale=(Quantum *) NULL;
if (max_value != (1U*QuantumRange))
{
*restrict q;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- intensity=PNMInteger(image,10);
- SetPixelRed(image,intensity,q);
+ intensity=PNMInteger(image,10,exception);
+ SetPixelGray(image,intensity,q);
if (scale != (Quantum *) NULL)
- SetPixelRed(image,scale[ConstrainPixel(image,(ssize_t) intensity,
- max_value)],q);
- SetPixelGreen(image,GetPixelRed(image,q),q);
- SetPixelBlue(image,GetPixelRed(image,q),q);
+ SetPixelGray(image,scale[ConstrainPixel(image,(ssize_t) intensity,
+ max_value,exception)],q);
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
*restrict q;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- pixel.red=(MagickRealType) PNMInteger(image,10);
- pixel.green=(MagickRealType) PNMInteger(image,10);
- pixel.blue=(MagickRealType) PNMInteger(image,10);
+ pixel.red=(double) PNMInteger(image,10,exception);
+ pixel.green=(double) PNMInteger(image,10,exception);
+ pixel.blue=(double) PNMInteger(image,10,exception);
if (scale != (Quantum *) NULL)
{
- pixel.red=(MagickRealType) scale[ConstrainPixel(image,(ssize_t)
- pixel.red,max_value)];
- pixel.green=(MagickRealType) scale[ConstrainPixel(image,
- (ssize_t) pixel.green,max_value)];
- pixel.blue=(MagickRealType) scale[ConstrainPixel(image,(ssize_t)
- pixel.blue,max_value)];
+ pixel.red=(double) scale[ConstrainPixel(image,(ssize_t)
+ pixel.red,max_value,exception)];
+ pixel.green=(double) scale[ConstrainPixel(image,
+ (ssize_t) pixel.green,max_value,exception)];
+ pixel.blue=(double) scale[ConstrainPixel(image,(ssize_t)
+ pixel.blue,max_value,exception)];
}
- SetPixelRed(image,pixel.red,q);
- SetPixelGreen(image,pixel.green,q);
- SetPixelBlue(image,pixel.blue,q);
+ SetPixelRed(image,ClampToQuantum(pixel.red),q);
+ SetPixelGreen(image,ClampToQuantum(pixel.green),q);
+ SetPixelBlue(image,ClampToQuantum(pixel.blue),q);
q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
/*
Convert PBM raw image to pixel packets.
*/
+ SetImageColorspace(image,GRAYColorspace,exception);
quantum_type=GrayQuantum;
if (image->storage_class == PseudoClass)
quantum_type=IndexQuantum;
if (count != (ssize_t) extent)
status=MagickFalse;
q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
/*
Convert PGM raw image to pixel packets.
*/
+ SetImageColorspace(image,GRAYColorspace,exception);
range=GetQuantumRange(image->depth);
quantum_type=GrayQuantum;
extent=(image->depth <= 8 ? 1 : 2)*image->columns;
if (count != (ssize_t) extent)
status=MagickFalse;
q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
for (x=0; x < (ssize_t) image->columns; x++)
{
p=PushCharPixel(p,&pixel);
- SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
- SetPixelGreen(image,GetPixelRed(image,q),q);
- SetPixelBlue(image,GetPixelRed(image,q),q);
+ SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
q+=GetPixelChannels(image);
}
}
for (x=0; x < (ssize_t) image->columns; x++)
{
p=PushShortPixel(MSBEndian,p,&pixel);
- SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
- SetPixelGreen(image,GetPixelRed(image,q),q);
- SetPixelBlue(image,GetPixelRed(image,q),q);
+ SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
q+=GetPixelChannels(image);
}
}
}
case '6':
{
- ImageType
- type;
-
QuantumAny
range;
/*
Convert PNM raster image to pixel packets.
*/
- type=BilevelType;
quantum_type=RGBQuantum;
extent=3*(image->depth <= 8 ? 1 : 2)*image->columns;
range=GetQuantumRange(image->depth);
quantum_info=AcquireQuantumInfo(image_info,image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
+ (void) SetQuantumEndian(image,quantum_info,MSBEndian);
for (y=0; y < (ssize_t) image->rows; y++)
{
MagickBooleanType
if (count != (ssize_t) extent)
status=MagickFalse;
q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
q+=GetPixelChannels(image);
}
}
- if ((type == BilevelType) || (type == GrayscaleType))
- {
- q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);
- for (x=0; x < (ssize_t) image->columns; x++)
- {
- if ((type == BilevelType) &&
- (IsPixelMonochrome(image,q) == MagickFalse))
- type=IsPixelGray(image,q) == MagickFalse ? UndefinedType :
- GrayscaleType;
- if ((type == GrayscaleType) &&
- (IsPixelGray(image,q) == MagickFalse))
- type=UndefinedType;
- if ((type != BilevelType) && (type != GrayscaleType))
- break;
- q+=GetPixelChannels(image);
- }
- }
sync=SyncAuthenticPixels(image,exception);
if (sync == MagickFalse)
status=MagickFalse;
quantum_info=DestroyQuantumInfo(quantum_info);
if (status == MagickFalse)
ThrowReaderException(CorruptImageError,"UnableToReadImageData");
- if (type != UndefinedType)
- image->type=type;
break;
}
case '7':
break;
}
}
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
channels++;
extent=channels*(image->depth <= 8 ? 1 : 2)*image->columns;
quantum_info=AcquireQuantumInfo(image_info,image);
if (count != (ssize_t) extent)
status=MagickFalse;
q=QueueAuthenticPixels(image,0,offset,image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
for (x=0; x < (ssize_t) image->columns; x++)
{
p=PushCharPixel(p,&pixel);
- SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
- SetPixelGreen(image,GetPixelRed(image,q),q);
- SetPixelBlue(image,GetPixelRed(image,q),q);
+ SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
SetPixelAlpha(image,OpaqueAlpha,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
p=PushCharPixel(p,&pixel);
SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
for (x=0; x < (ssize_t) image->columns; x++)
{
p=PushShortPixel(MSBEndian,p,&pixel);
- SetPixelRed(image,ScaleAnyToQuantum(pixel,range),q);
- SetPixelGreen(image,GetPixelRed(image,q),q);
- SetPixelBlue(image,GetPixelRed(image,q),q);
+ SetPixelGray(image,ScaleAnyToQuantum(pixel,range),q);
SetPixelAlpha(image,OpaqueAlpha,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
p=PushShortPixel(MSBEndian,p,&pixel);
SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
p=PushCharPixel(p,&pixel);
SetPixelBlack(image,ScaleAnyToQuantum(pixel,range),q);
SetPixelAlpha(image,OpaqueAlpha,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
p=PushCharPixel(p,&pixel);
SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
p=PushShortPixel(MSBEndian,p,&pixel);
SetPixelBlack(image,ScaleAnyToQuantum(pixel,range),q);
SetPixelAlpha(image,OpaqueAlpha,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
p=PushShortPixel(MSBEndian,p,&pixel);
SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
p=PushCharPixel(p,&pixel);
SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
SetPixelAlpha(image,OpaqueAlpha,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
p=PushCharPixel(p,&pixel);
SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
p=PushShortPixel(MSBEndian,p,&pixel);
SetPixelBlue(image,ScaleAnyToQuantum(pixel,range),q);
SetPixelAlpha(image,OpaqueAlpha,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
p=PushShortPixel(MSBEndian,p,&pixel);
SetPixelAlpha(image,ScaleAnyToQuantum(pixel,range),q);
/*
Convert PFM raster image to pixel packets.
*/
+ if (format == 'f')
+ SetImageColorspace(image,GRAYColorspace,exception);
quantum_type=format == 'f' ? GrayQuantum : RGBQuantum;
image->endian=quantum_scale < 0.0 ? LSBEndian : MSBEndian;
image->depth=32;
status=SetQuantumFormat(image,quantum_info,FloatingPointQuantumFormat);
if (status == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
- SetQuantumScale(quantum_info,(MagickRealType) QuantumRange*
- fabs(quantum_scale));
+ SetQuantumScale(quantum_info,(double) QuantumRange*fabs(quantum_scale));
extent=GetQuantumExtent(image,quantum_info,quantum_type);
for (y=0; y < (ssize_t) image->rows; y++)
{
status=MagickFalse;
q=QueueAuthenticPixels(image,0,(ssize_t) (image->rows-offset-1),
image->columns,1,exception);
- if (q == (const Quantum *) NULL)
+ if (q == (Quantum *) NULL)
{
status=MagickFalse;
continue;
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
}
if (EOFBlob(image) != MagickFalse)
- (void) ThrowMagickException(exception,GetMagickModule(),CorruptImageError,
- "UnexpectedEndOfFile","`%s'",image->filename);
+ {
+ (void) ThrowMagickException(exception,GetMagickModule(),
+ CorruptImageError,"UnexpectedEndOfFile","`%s'",image->filename);
+ break;
+ }
/*
Proceed to next image.
*/
/*
Allocate next image structure.
*/
- AcquireNextImage(image_info,image);
+ AcquireNextImage(image_info,image,exception);
if (GetNextImageInList(image) == (Image *) NULL)
{
image=DestroyImageList(image);
%
% The format of the WritePNMImage method is:
%
-% MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image)
+% MagickBooleanType WritePNMImage(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 WritePNMImage(const ImageInfo *image_info,Image *image)
+static MagickBooleanType WritePNMImage(const ImageInfo *image_info,Image *image,
+ ExceptionInfo *exception)
{
char
buffer[MaxTextExtent],
assert(image->signature == MagickSignature);
if (image->debug != MagickFalse)
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
- status=OpenBlob(image_info,image,WriteBinaryBlobMode,&image->exception);
+ assert(exception != (ExceptionInfo *) NULL);
+ assert(exception->signature == MagickSignature);
+ status=OpenBlob(image_info,image,WriteBinaryBlobMode,exception);
if (status == MagickFalse)
return(status);
scene=0;
case 'f':
{
format='F';
- if (IsImageGray(image,&image->exception) != MagickFalse)
+ if (IsImageGray(image,exception) != MagickFalse)
format='f';
break;
}
case 'n':
{
if ((image_info->type != TrueColorType) &&
- (IsImageGray(image,&image->exception) != MagickFalse))
+ (IsImageGray(image,exception) != MagickFalse))
{
format='5';
if (image_info->compression == NoCompression)
format='2';
- if (IsImageMonochrome(image,&image->exception) != MagickFalse)
+ if (IsImageMonochrome(image,exception) != MagickFalse)
{
format='4';
if (image_info->compression == NoCompression)
}
(void) FormatLocaleString(buffer,MaxTextExtent,"P%c\n",format);
(void) WriteBlobString(image,buffer);
- value=GetImageProperty(image,"comment");
+ value=GetImageProperty(image,"comment",exception);
if (value != (const char *) NULL)
{
register const char
}
if (format != '7')
{
- if (image->colorspace != RGBColorspace)
- (void) TransformImageColorspace(image,RGBColorspace);
(void) FormatLocaleString(buffer,MaxTextExtent,"%.20g %.20g\n",
(double) image->columns,(double) image->rows);
(void) WriteBlobString(image,buffer);
"WIDTH %.20g\nHEIGHT %.20g\n",(double) image->columns,(double)
image->rows);
(void) WriteBlobString(image,buffer);
- quantum_type=GetQuantumType(image,&image->exception);
+ quantum_type=GetQuantumType(image,exception);
switch (quantum_type)
{
case CMYKQuantum:
default:
{
quantum_type=RGBQuantum;
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
quantum_type=RGBAQuantum;
packet_size=3;
(void) CopyMagickString(type,"RGB",MaxTextExtent);
break;
}
}
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
packet_size++;
(void) ConcatenateMagickString(type,"_ALPHA",MaxTextExtent);
image->depth=16;
(void) FormatLocaleString(buffer,MaxTextExtent,
"DEPTH %.20g\nMAXVAL %.20g\n",(double) packet_size,(double)
- GetQuantumRange(image->depth));
+ ((MagickOffsetType) GetQuantumRange(image->depth)));
(void) WriteBlobString(image,buffer);
(void) FormatLocaleString(buffer,MaxTextExtent,"TUPLTYPE %s\nENDHDR\n",
type);
/*
Convert image to a PBM image.
*/
+ if (IsImageGray(image,exception) == MagickFalse)
+ (void) TransformImageColorspace(image,GRAYColorspace,exception);
q=pixels;
for (y=0; y < (ssize_t) image->rows; y++)
{
register ssize_t
x;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
/*
Convert image to a PGM image.
*/
+ if (IsImageGray(image,exception) == MagickFalse)
+ (void) TransformImageColorspace(image,GRAYColorspace,exception);
if (image->depth <= 8)
(void) WriteBlobString(image,"255\n");
else
register ssize_t
x;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
/*
Convert image to a PNM image.
*/
+ if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
if (image->depth <= 8)
(void) WriteBlobString(image,"255\n");
else
register ssize_t
x;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
/*
Convert image to a PBM image.
*/
+ if (IsImageGray(image,exception) == MagickFalse)
+ (void) TransformImageColorspace(image,GRAYColorspace,exception);
image->depth=1;
quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
if (quantum_info == (QuantumInfo *) NULL)
register const Quantum
*restrict p;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
- GrayQuantum,pixels,&image->exception);
+ GrayQuantum,pixels,exception);
count=WriteBlob(image,extent,pixels);
if (count != (ssize_t) extent)
break;
/*
Convert image to a PGM image.
*/
+ if (IsImageGray(image,exception) == MagickFalse)
+ (void) TransformImageColorspace(image,GRAYColorspace,exception);
if (image->depth > 8)
image->depth=16;
(void) FormatLocaleString(buffer,MaxTextExtent,"%.20g\n",(double)
- GetQuantumRange(image->depth));
+ ((MagickOffsetType) GetQuantumRange(image->depth)));
(void) WriteBlobString(image,buffer);
quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
if (quantum_info == (QuantumInfo *) NULL)
register ssize_t
x;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
q=pixels;
if ((image->depth == 8) || (image->depth == 16))
extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
- GrayQuantum,pixels,&image->exception);
+ GrayQuantum,pixels,exception);
else
{
if (image->depth <= 8)
/*
Convert image to a PNM image.
*/
+ if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
if (image->depth > 8)
image->depth=16;
(void) FormatLocaleString(buffer,MaxTextExtent,"%.20g\n",(double)
- GetQuantumRange(image->depth));
+ ((MagickOffsetType) GetQuantumRange(image->depth)));
(void) WriteBlobString(image,buffer);
quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
if (quantum_info == (QuantumInfo *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
+ (void) SetQuantumEndian(image,quantum_info,MSBEndian);
pixels=GetQuantumPixels(quantum_info);
extent=GetQuantumExtent(image,quantum_info,quantum_type);
range=GetQuantumRange(image->depth);
register ssize_t
x;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
q=pixels;
if ((image->depth == 8) || (image->depth == 16))
extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
- quantum_type,pixels,&image->exception);
+ quantum_type,pixels,exception);
else
{
if (image->depth <= 8)
register ssize_t
x;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
q=pixels;
if ((image->depth == 8) || (image->depth == 16))
extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
- quantum_type,pixels,&image->exception);
+ quantum_type,pixels,exception);
else
{
switch (quantum_type)
{
pixel=ScaleQuantumToAny(GetPixelIntensity(image,p),range);
q=PopCharPixel((unsigned char) pixel,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
pixel=(unsigned char) ScaleQuantumToAny(
GetPixelAlpha(image,p),range);
{
pixel=ScaleQuantumToAny(GetPixelIntensity(image,p),range);
q=PopShortPixel(MSBEndian,(unsigned short) pixel,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
pixel=(unsigned char) ScaleQuantumToAny(
GetPixelAlpha(image,p),range);
q=PopCharPixel((unsigned char) pixel,q);
pixel=ScaleQuantumToAny(GetPixelBlack(image,p),range);
q=PopCharPixel((unsigned char) pixel,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
pixel=ScaleQuantumToAny(GetPixelAlpha(image,p),range);
q=PopCharPixel((unsigned char) pixel,q);
q=PopShortPixel(MSBEndian,(unsigned short) pixel,q);
pixel=ScaleQuantumToAny(GetPixelBlack(image,p),range);
q=PopShortPixel(MSBEndian,(unsigned short) pixel,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
pixel=ScaleQuantumToAny(GetPixelAlpha(image,p),range);
q=PopShortPixel(MSBEndian,(unsigned short) pixel,q);
q=PopCharPixel((unsigned char) pixel,q);
pixel=ScaleQuantumToAny(GetPixelBlue(image,p),range);
q=PopCharPixel((unsigned char) pixel,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
pixel=ScaleQuantumToAny(GetPixelAlpha(image,p),range);
q=PopCharPixel((unsigned char) pixel,q);
q=PopShortPixel(MSBEndian,(unsigned short) pixel,q);
pixel=ScaleQuantumToAny(GetPixelBlue(image,p),range);
q=PopShortPixel(MSBEndian,(unsigned short) pixel,q);
- if (image->matte != MagickFalse)
+ if (image->alpha_trait == BlendPixelTrait)
{
pixel=ScaleQuantumToAny(GetPixelAlpha(image,p),range);
q=PopShortPixel(MSBEndian,(unsigned short) pixel,q);
case 'F':
case 'f':
{
- (void) WriteBlobString(image,image->endian != LSBEndian ? "1.0\n" :
- "-1.0\n");
+ (void) WriteBlobString(image,image->endian == LSBEndian ? "-1.0\n" :
+ "1.0\n");
image->depth=32;
quantum_type=format == 'f' ? GrayQuantum : RGBQuantum;
quantum_info=AcquireQuantumInfo((const ImageInfo *) NULL,image);
register const Quantum
*restrict p;
- p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
+ p=GetVirtualPixels(image,0,y,image->columns,1,exception);
if (p == (const Quantum *) NULL)
break;
extent=ExportQuantumPixels(image,(CacheView *) NULL,quantum_info,
- quantum_type,pixels,&image->exception);
+ quantum_type,pixels,exception);
(void) WriteBlob(image,extent,pixels);
if (image->previous == (Image *) NULL)
{