% July 1992 %
% %
% %
-% Copyright 1999-2011 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2012 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/color.h"
-#include "magick/color-private.h"
-#include "magick/colormap.h"
-#include "magick/colorspace.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/property.h"
-#include "magick/quantum-private.h"
-#include "magick/static.h"
-#include "magick/string_.h"
-#include "magick/module.h"
+#include "MagickCore/studio.h"
+#include "MagickCore/attribute.h"
+#include "MagickCore/blob.h"
+#include "MagickCore/blob-private.h"
+#include "MagickCore/cache.h"
+#include "MagickCore/color.h"
+#include "MagickCore/color-private.h"
+#include "MagickCore/colormap.h"
+#include "MagickCore/colorspace.h"
+#include "MagickCore/colorspace-private.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/property.h"
+#include "MagickCore/quantum-private.h"
+#include "MagickCore/static.h"
+#include "MagickCore/string_.h"
+#include "MagickCore/module.h"
\f
/*
Typedef declaractions.
Forward declarations.
*/
static MagickBooleanType
- WriteSGIImage(const ImageInfo *,Image *);
+ WriteSGIImage(const ImageInfo *,Image *,ExceptionInfo *);
/*
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% %
MagickSizeType
number_pixels;
- register IndexPacket
- *indexes;
-
- register PixelPacket
+ register Quantum
*q;
register ssize_t
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)
{
iris_info.name);
iris_info.name[sizeof(iris_info.name)-1]='\0';
if (*iris_info.name != '\0')
- (void) SetImageProperty(image,"label",iris_info.name);
+ (void) SetImageProperty(image,"label",iris_info.name,exception);
iris_info.pixel_format=ReadBlobMSBLong(image);
if (iris_info.pixel_format != 0)
ThrowReaderException(CorruptImageError,"ImproperImageHeader");
{
p=iris_pixels+(image->rows-y-1)*8*image->columns;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- SetRedPixelComponent(q,ScaleShortToQuantum((unsigned short)
- ((*(p+0) << 8) | (*(p+1)))));
- SetGreenPixelComponent(q,ScaleShortToQuantum((unsigned short)
- ((*(p+2) << 8) | (*(p+3)))));
- SetBluePixelComponent(q,ScaleShortToQuantum((unsigned short)
- ((*(p+4) << 8) | (*(p+5)))));
- SetOpacityPixelComponent(q,OpaqueOpacity);
+ SetPixelRed(image,ScaleShortToQuantum((unsigned short)
+ ((*(p+0) << 8) | (*(p+1)))),q);
+ SetPixelGreen(image,ScaleShortToQuantum((unsigned short)
+ ((*(p+2) << 8) | (*(p+3)))),q);
+ SetPixelBlue(image,ScaleShortToQuantum((unsigned short)
+ ((*(p+4) << 8) | (*(p+5)))),q);
+ SetPixelAlpha(image,OpaqueAlpha,q);
if (image->matte != MagickFalse)
- SetAlphaPixelComponent(q,ScaleShortToQuantum((unsigned short)
- ((*(p+6) << 8) | (*(p+7)))));
+ SetPixelAlpha(image,ScaleShortToQuantum((unsigned short)
+ ((*(p+6) << 8) | (*(p+7)))),q);
p+=8;
- q++;
+ q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
{
p=iris_pixels+(image->rows-y-1)*4*image->columns;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
for (x=0; x < (ssize_t) image->columns; x++)
{
- SetRedPixelComponent(q,ScaleCharToQuantum(*p));
- q->green=ScaleCharToQuantum(*(p+1));
- q->blue=ScaleCharToQuantum(*(p+2));
- SetOpacityPixelComponent(q,OpaqueOpacity);
+ SetPixelRed(image,ScaleCharToQuantum(*p),q);
+ SetPixelGreen(image,ScaleCharToQuantum(*(p+1)),q);
+ SetPixelBlue(image,ScaleCharToQuantum(*(p+2)),q);
+ SetPixelAlpha(image,OpaqueAlpha,q);
if (image->matte != MagickFalse)
- SetAlphaPixelComponent(q,ScaleCharToQuantum(*(p+3)));
+ SetPixelAlpha(image,ScaleCharToQuantum(*(p+3)),q);
p+=4;
- q++;
+ q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
- image->rows);
+ image->rows);
if (status == MagickFalse)
break;
}
/*
Create grayscale map.
*/
- if (AcquireImageColormap(image,image->colors) == MagickFalse)
+ if (AcquireImageColormap(image,image->colors,exception) == MagickFalse)
ThrowReaderException(ResourceLimitError,"MemoryAllocationFailed");
/*
Convert SGI image to PseudoClass pixel packets.
{
p=iris_pixels+(image->rows-y-1)*8*image->columns;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
- indexes=GetAuthenticIndexQueue(image);
for (x=0; x < (ssize_t) image->columns; x++)
{
quantum=(*p << 8);
quantum|=(*(p+1));
- SetIndexPixelComponent(indexes+x,quantum);
+ SetPixelIndex(image,quantum,q);
p+=8;
- q++;
+ q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
{
p=iris_pixels+(image->rows-y-1)*4*image->columns;
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
- if (q == (PixelPacket *) NULL)
+ if (q == (Quantum *) NULL)
break;
- indexes=GetAuthenticIndexQueue(image);
for (x=0; x < (ssize_t) image->columns; x++)
{
- SetIndexPixelComponent(indexes+x,*p);
+ SetPixelIndex(image,*p,q);
p+=4;
- q++;
+ q+=GetPixelChannels(image);
}
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
break;
}
}
- (void) SyncImage(image);
+ (void) SyncImage(image,exception);
}
iris_pixels=(unsigned char *) RelinquishMagickMemory(iris_pixels);
if (EOFBlob(image) != MagickFalse)
/*
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 WriteSGIImage method is:
%
-% MagickBooleanType WriteSGIImage(const ImageInfo *image_info,Image *image)
+% MagickBooleanType WriteSGIImage(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 size_t SGIEncode(unsigned char *pixels,size_t length,
return((size_t) (q-packets));
}
-static MagickBooleanType WriteSGIImage(const ImageInfo *image_info,Image *image)
+static MagickBooleanType WriteSGIImage(const ImageInfo *image_info,Image *image,
+ ExceptionInfo *exception)
{
CompressionType
compression;
SGIInfo
iris_info;
- register const PixelPacket
+ register const Quantum
*p;
register ssize_t
(void) LogMagickEvent(TraceEvent,GetMagickModule(),"%s",image->filename);
if ((image->columns > 65535UL) || (image->rows > 65535UL))
ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
- 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;
/*
Initialize SGI raster file header.
*/
- if (image->colorspace != RGBColorspace)
- (void) TransformImageColorspace(image,RGBColorspace);
+ if (IssRGBCompatibleColorspace(image->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
(void) ResetMagickMemory(&iris_info,0,sizeof(iris_info));
iris_info.magic=0x01DA;
compression=image->compression;
else
{
if ((image_info->type != TrueColorType) &&
- (IsGrayImage(image,&image->exception) != MagickFalse))
+ (IsImageGray(image,exception) != MagickFalse))
{
iris_info.dimension=2;
iris_info.depth=1;
}
iris_info.minimum_value=0;
iris_info.maximum_value=(size_t) (image->depth <= 8 ?
- 1UL*ScaleQuantumToChar((Quantum) QuantumRange) :
- 1UL*ScaleQuantumToShort((Quantum) QuantumRange));
+ 1UL*ScaleQuantumToChar(QuantumRange) :
+ 1UL*ScaleQuantumToShort(QuantumRange));
/*
Write SGI header.
*/
(void) WriteBlobMSBLong(image,(unsigned int) iris_info.minimum_value);
(void) WriteBlobMSBLong(image,(unsigned int) iris_info.maximum_value);
(void) WriteBlobMSBLong(image,(unsigned int) iris_info.sans);
- value=GetImageProperty(image,"label");
+ value=GetImageProperty(image,"label",exception);
if (value != (const char *) NULL)
(void) CopyMagickString(iris_info.name,value,sizeof(iris_info.name));
(void) WriteBlob(image,sizeof(iris_info.name),(unsigned char *)
*/
for (y=0; y < (ssize_t) image->rows; y++)
{
- 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;
if (image->depth <= 8)
for (x=0; x < (ssize_t) image->columns; x++)
q=(unsigned char *) iris_pixels;
q+=((iris_info.rows-1)-y)*(4*iris_info.columns)+4*x;
- *q++=ScaleQuantumToChar(GetRedPixelComponent(p));
- *q++=ScaleQuantumToChar(GetGreenPixelComponent(p));
- *q++=ScaleQuantumToChar(GetBluePixelComponent(p));
- *q++=ScaleQuantumToChar(GetAlphaPixelComponent(p));
- p++;
+ *q++=ScaleQuantumToChar(GetPixelRed(image,p));
+ *q++=ScaleQuantumToChar(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToChar(GetPixelBlue(image,p));
+ *q++=ScaleQuantumToChar(GetPixelAlpha(image,p));
+ p+=GetPixelChannels(image);
}
else
for (x=0; x < (ssize_t) image->columns; x++)
q=(unsigned short *) iris_pixels;
q+=((iris_info.rows-1)-y)*(4*iris_info.columns)+4*x;
- *q++=ScaleQuantumToShort(GetRedPixelComponent(p));
- *q++=ScaleQuantumToShort(GetGreenPixelComponent(p));
- *q++=ScaleQuantumToShort(GetBluePixelComponent(p));
- *q++=ScaleQuantumToShort(GetAlphaPixelComponent(p));
- p++;
+ *q++=ScaleQuantumToShort(GetPixelRed(image,p));
+ *q++=ScaleQuantumToShort(GetPixelGreen(image,p));
+ *q++=ScaleQuantumToShort(GetPixelBlue(image,p));
+ *q++=ScaleQuantumToShort(GetPixelAlpha(image,p));
+ p+=GetPixelChannels(image);
}
if (image->previous == (Image *) NULL)
{