% July 1992 %
% %
% %
-% Copyright 1999-2010 ImageMagick Studio LLC, a non-profit organization %
+% Copyright 1999-2011 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 "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"
char
comment[512];
- unsigned long
+ unsigned int
rows,
columns,
subrows;
- long
+ int
x_offset,
y_offset;
x_bits_per_pixel,
y_bits_per_pixel;
- unsigned long
+ unsigned int
location_type,
location_dimension,
number_of_images,
int
bit;
- long
+ ssize_t
y;
MagickBooleanType
register IndexPacket
*indexes;
- register long
+ register ssize_t
x;
register PixelPacket
*q;
- register long
+ register ssize_t
i;
register unsigned char
buffer[7],
*viff_pixels;
- unsigned long
+ size_t
bytes_per_pixel,
lsb_first,
max_packets,
viff_info.rows=ReadBlobLSBLong(image);
viff_info.columns=ReadBlobLSBLong(image);
viff_info.subrows=ReadBlobLSBLong(image);
- viff_info.x_offset=(long) ReadBlobLSBLong(image);
- viff_info.y_offset=(long) ReadBlobLSBLong(image);
+ viff_info.x_offset=(int) ReadBlobLSBLong(image);
+ viff_info.y_offset=(int) ReadBlobLSBLong(image);
viff_info.x_bits_per_pixel=(float) ReadBlobLSBLong(image);
viff_info.y_bits_per_pixel=(float) ReadBlobLSBLong(image);
viff_info.location_type=ReadBlobLSBLong(image);
viff_info.rows=ReadBlobMSBLong(image);
viff_info.columns=ReadBlobMSBLong(image);
viff_info.subrows=ReadBlobMSBLong(image);
- viff_info.x_offset=(long) ReadBlobMSBLong(image);
- viff_info.y_offset=(long) ReadBlobMSBLong(image);
+ viff_info.x_offset=(int) ReadBlobMSBLong(image);
+ viff_info.y_offset=(int) ReadBlobMSBLong(image);
viff_info.x_bits_per_pixel=(float) ReadBlobMSBLong(image);
viff_info.y_bits_per_pixel=(float) ReadBlobMSBLong(image);
viff_info.location_type=ReadBlobMSBLong(image);
}
default: break;
}
- for (i=0; i < (long) (viff_info.map_rows*image->colors); i++)
+ for (i=0; i < (ssize_t) (viff_info.map_rows*image->colors); i++)
{
switch ((int) viff_info.map_storage_type)
{
case VFF_MAPTYP_DOUBLE: value=((double *) viff_colormap)[i]; break;
default: value=1.0*viff_colormap[i]; break;
}
- if (i < (long) image->colors)
+ if (i < (ssize_t) image->colors)
{
image->colormap[i].red=ScaleCharToQuantum((unsigned char) value);
image->colormap[i].green=
image->colormap[i].blue=ScaleCharToQuantum((unsigned char) value);
}
else
- if (i < (long) (2*image->colors))
+ if (i < (ssize_t) (2*image->colors))
image->colormap[i % image->colors].green=
ScaleCharToQuantum((unsigned char) value);
else
- if (i < (long) (3*image->colors))
+ if (i < (ssize_t) (3*image->colors))
image->colormap[i % image->colors].blue=
ScaleCharToQuantum((unsigned char) value);
}
if (viff_info.data_storage_type == VFF_TYP_BIT)
max_packets=((image->columns+7UL) >> 3UL)*image->rows;
else
- max_packets=(unsigned long) (number_pixels*viff_info.number_data_bands);
+ max_packets=(size_t) (number_pixels*viff_info.number_data_bands);
viff_pixels=(unsigned char *) AcquireQuantumMemory(max_packets,
bytes_per_pixel*sizeof(*viff_pixels));
if (viff_pixels == (unsigned char *) NULL)
}
max_value=value;
min_value=value;
- for (i=0; i < (long) max_packets; i++)
+ for (i=0; i < (ssize_t) max_packets; i++)
{
switch ((int) viff_info.data_storage_type)
{
Convert pixels to Quantum size.
*/
p=(unsigned char *) viff_pixels;
- for (i=0; i < (long) max_packets; i++)
+ for (i=0; i < (ssize_t) max_packets; i++)
{
switch ((int) viff_info.data_storage_type)
{
*/
(void) SetImageType(image,BilevelType);
(void) SetImageType(image,PaletteType);
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
- for (x=0; x < (long) (image->columns-7); x+=8)
+ for (x=0; x < (ssize_t) (image->columns-7); x+=8)
{
for (bit=0; bit < 8; bit++)
if (PixelIntensity(q) < ((MagickRealType) QuantumRange/2.0))
{
- quantum=(unsigned long) indexes[x+bit];
+ quantum=(size_t) indexes[x+bit];
quantum|=0x01;
indexes[x+bit]=(IndexPacket) quantum;
}
}
if ((image->columns % 8) != 0)
{
- for (bit=0; bit < (long) (image->columns % 8); bit++)
+ for (bit=0; bit < (ssize_t) (image->columns % 8); bit++)
if (PixelIntensity(q) < ((MagickRealType) QuantumRange/2.0))
{
- quantum=(unsigned long) indexes[x+bit];
+ quantum=(size_t) indexes[x+bit];
quantum|=0x01;
indexes[x+bit]=(IndexPacket) quantum;
}
break;
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,LoadImageTag,y,image->rows);
+ status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
+ image->rows);
if (status == MagickFalse)
break;
}
}
else
if (image->storage_class == PseudoClass)
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
indexes=GetAuthenticIndexQueue(image);
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
indexes[x]=(IndexPacket) (*p++);
if (SyncAuthenticPixels(image,exception) == MagickFalse)
break;
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,LoadImageTag,y,image->rows);
+ status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
+ image->rows);
if (status == MagickFalse)
break;
}
Convert DirectColor scanline.
*/
number_pixels=(MagickSizeType) image->columns*image->rows;
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
q=QueueAuthenticPixels(image,0,y,image->columns,1,exception);
if (q == (PixelPacket *) NULL)
break;
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
q->red=ScaleCharToQuantum(*p);
q->green=ScaleCharToQuantum(*(p+number_pixels));
q->blue=ScaleCharToQuantum(*(p+2*number_pixels));
if (image->colors != 0)
{
- q->red=image->colormap[(long) q->red].red;
- q->green=image->colormap[(long) q->green].green;
- q->blue=image->colormap[(long) q->blue].blue;
+ q->red=image->colormap[(ssize_t) q->red].red;
+ q->green=image->colormap[(ssize_t) q->green].green;
+ q->blue=image->colormap[(ssize_t) q->blue].blue;
}
q->opacity=(Quantum) (image->matte ? QuantumRange-
ScaleCharToQuantum(*(p+number_pixels*3)) : OpaqueOpacity);
break;
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,LoadImageTag,y,image->rows);
+ status=SetImageProgress(image,LoadImageTag,(MagickOffsetType) y,
+ image->rows);
if (status == MagickFalse)
break;
}
%
% The format of the RegisterVIFFImage method is:
%
-% unsigned long RegisterVIFFImage(void)
+% size_t RegisterVIFFImage(void)
%
*/
-ModuleExport unsigned long RegisterVIFFImage(void)
+ModuleExport size_t RegisterVIFFImage(void)
{
MagickInfo
*entry;
reserve[3],
comment[512];
- unsigned long
+ size_t
rows,
columns,
subrows;
- long
+ int
x_offset,
y_offset;
unsigned int
x_bits_per_pixel,
- y_bits_per_pixel;
-
- unsigned long
+ y_bits_per_pixel,
location_type,
location_dimension,
number_of_images,
const char
*value;
- long
+ ssize_t
y;
MagickBooleanType
register const PixelPacket
*p;
- register long
+ register ssize_t
x;
- register long
+ register ssize_t
i;
register unsigned char
viff_info.map_scheme=VFF_MS_ONEPERBAND;
viff_info.map_storage_type=VFF_MAPTYP_1_BYTE;
viff_info.map_rows=3;
- viff_info.map_columns=image->colors;
+ viff_info.map_columns=(unsigned int) image->colors;
}
else
if (image->colors <= 2)
buffer[7]=(unsigned char) viff_info.reserve[2];
(void) WriteBlob(image,8,buffer);
(void) WriteBlob(image,512,(unsigned char *) viff_info.comment);
- (void) WriteBlobMSBLong(image,viff_info.rows);
- (void) WriteBlobMSBLong(image,viff_info.columns);
- (void) WriteBlobMSBLong(image,viff_info.subrows);
- (void) WriteBlobMSBLong(image,(unsigned long) viff_info.x_offset);
- (void) WriteBlobMSBLong(image,(unsigned long) viff_info.y_offset);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.rows);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.columns);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.subrows);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.x_offset);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.y_offset);
viff_info.x_bits_per_pixel=1U*(63 << 24) | (128 << 16);
- (void) WriteBlobMSBLong(image,(unsigned long) viff_info.x_bits_per_pixel);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.x_bits_per_pixel);
viff_info.y_bits_per_pixel=1U*(63 << 24) | (128 << 16);
- (void) WriteBlobMSBLong(image,(unsigned long) viff_info.y_bits_per_pixel);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.y_bits_per_pixel);
(void) WriteBlobMSBLong(image,viff_info.location_type);
(void) WriteBlobMSBLong(image,viff_info.location_dimension);
- (void) WriteBlobMSBLong(image,viff_info.number_of_images);
- (void) WriteBlobMSBLong(image,viff_info.number_data_bands);
- (void) WriteBlobMSBLong(image,viff_info.data_storage_type);
- (void) WriteBlobMSBLong(image,viff_info.data_encode_scheme);
- (void) WriteBlobMSBLong(image,viff_info.map_scheme);
- (void) WriteBlobMSBLong(image,viff_info.map_storage_type);
- (void) WriteBlobMSBLong(image,viff_info.map_rows);
- (void) WriteBlobMSBLong(image,viff_info.map_columns);
- (void) WriteBlobMSBLong(image,viff_info.map_subrows);
- (void) WriteBlobMSBLong(image,viff_info.map_enable);
- (void) WriteBlobMSBLong(image,viff_info.maps_per_cycle);
- (void) WriteBlobMSBLong(image,viff_info.color_space_model);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.number_of_images);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.number_data_bands);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.data_storage_type);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.data_encode_scheme);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.map_scheme);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.map_storage_type);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.map_rows);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.map_columns);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.map_subrows);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.map_enable);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.maps_per_cycle);
+ (void) WriteBlobMSBLong(image,(unsigned int) viff_info.color_space_model);
for (i=0; i < 420; i++)
(void) WriteBlobByte(image,'\0');
/*
Convert DirectClass packet to VIFF RGB pixel.
*/
number_pixels=(MagickSizeType) image->columns*image->rows;
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
if (p == (const PixelPacket *) NULL)
break;
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
*q=ScaleQuantumToChar(GetRedPixelComponent(p));
*(q+number_pixels)=ScaleQuantumToChar(GetGreenPixelComponent(p));
}
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,SaveImageTag,y,image->rows);
+ status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
+ image->rows);
if (status == MagickFalse)
break;
}
if (viff_colormap == (unsigned char *) NULL)
ThrowWriterException(ResourceLimitError,"MemoryAllocationFailed");
q=viff_colormap;
- for (i=0; i < (long) image->colors; i++)
+ for (i=0; i < (ssize_t) image->colors; i++)
*q++=ScaleQuantumToChar(image->colormap[i].red);
- for (i=0; i < (long) image->colors; i++)
+ for (i=0; i < (ssize_t) image->colors; i++)
*q++=ScaleQuantumToChar(image->colormap[i].green);
- for (i=0; i < (long) image->colors; i++)
+ for (i=0; i < (ssize_t) image->colors; i++)
*q++=ScaleQuantumToChar(image->colormap[i].blue);
(void) WriteBlob(image,3*image->colors,viff_colormap);
viff_colormap=(unsigned char *) RelinquishMagickMemory(viff_colormap);
Convert PseudoClass packet to VIFF colormapped pixels.
*/
q=viff_pixels;
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetVirtualPixels(image,0,y,image->columns,1,&image->exception);
if (p == (const PixelPacket *) NULL)
break;
indexes=GetVirtualIndexQueue(image);
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
*q++=(unsigned char) indexes[x];
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,SaveImageTag,y,image->rows);
+ status=SetImageProgress(image,SaveImageTag,(MagickOffsetType) y,
+ image->rows);
if (status == MagickFalse)
break;
}
else
if (image->colors <= 2)
{
- long
+ ssize_t
x,
y;
Convert PseudoClass image to a VIFF monochrome image.
*/
(void) SetImageType(image,BilevelType);
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetVirtualPixels(image,0,y,image->columns,1,
&image->exception);
indexes=GetVirtualIndexQueue(image);
bit=0;
byte=0;
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
byte>>=1;
if (PixelIntensity(p) < ((MagickRealType) QuantumRange/2.0))
*q++=byte >> (8-bit);
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,SaveImageTag,y,image->rows);
+ status=SetImageProgress(image,SaveImageTag,(MagickOffsetType)
+ y,image->rows);
if (status == MagickFalse)
break;
}
/*
Convert PseudoClass packet to VIFF grayscale pixel.
*/
- for (y=0; y < (long) image->rows; y++)
+ for (y=0; y < (ssize_t) image->rows; y++)
{
p=GetVirtualPixels(image,0,y,image->columns,1,
&image->exception);
if (p == (const PixelPacket *) NULL)
break;
- for (x=0; x < (long) image->columns; x++)
+ for (x=0; x < (ssize_t) image->columns; x++)
{
*q++=(unsigned char) PixelIntensityToQuantum(p);
p++;
}
if (image->previous == (Image *) NULL)
{
- status=SetImageProgress(image,SaveImageTag,y,image->rows);
+ status=SetImageProgress(image,SaveImageTag,(MagickOffsetType)
+ y,image->rows);
if (status == MagickFalse)
break;
}