Fix minor -Wconversion warnings in ImageIO

The old implementation seems harmless. I have added explicit casts to
quiet the warnings.
This commit is contained in:
Laurent Rineau 2016-04-22 12:12:14 +02:00
parent 810538d221
commit 589a45e65e
12 changed files with 127 additions and 125 deletions

View File

@ -608,9 +608,9 @@ void _get_image_bounding_box(_image* im,
*x_min = im->tx;
*y_min = im->ty;
*z_min = im->tz;
*x_max = (im->xdim - 1.0f)*(im->vx) + *x_min ;
*y_max = (im->ydim - 1.0f)*(im->vy) + *y_min ;
*z_max = (im->zdim - 1.0f)*(im->vz) + *z_min ;
*x_max = (double(im->xdim) - 1.0)*(im->vx) + *x_min ;
*y_max = (double(im->ydim) - 1.0)*(im->vy) + *y_min ;
*z_max = (double(im->zdim) - 1.0)*(im->vz) + *z_min ;
}
/* Free an image descriptor */
@ -1102,7 +1102,7 @@ static void _swapImageData( _image *im )
ptr3 = ptr4 = (unsigned short int *) im->data;
while( length-- ) {
si = *ptr3++;
*ptr4++ = ((si >> 8) & 0xff) | (si << 8);
*ptr4++ = (unsigned short int)(((si >> 8) & 0xff) | (si << 8));
}
}
@ -1570,10 +1570,10 @@ float triLinInterp(const _image* image,
float posz,
float value_outside /*= 0.f */)
{
const int dimx = image->xdim;
const int dimy = image->ydim;
const int dimz = image->zdim;
const int dimxy = dimx*dimy;
const std::size_t dimx = image->xdim;
const std::size_t dimy = image->ydim;
const std::size_t dimz = image->zdim;
const std::size_t dimxy = dimx*dimy;
if(posx < 0.f || posy < 0.f || posz < 0.f )
return value_outside;
@ -1594,10 +1594,10 @@ float triLinInterp(const _image* image,
const int j2 = j1 + 1;
const int k2 = k1 + 1;
const float KI2 = i2-posz;
const float KI1 = posz-i1;
const float KJ2 = j2-posy;
const float KJ1 = posy-j1;
const float KI2 = float(i2)-posz;
const float KI1 = posz-float(i1);
const float KJ2 = float(j2)-posy;
const float KJ1 = posy-float(j1);
CGAL_IMAGE_IO_CASE
(image,
@ -1605,11 +1605,11 @@ float triLinInterp(const _image* image,
return (((float)array[i1 * dimxy + j1 * dimx + k1] * KI2 +
(float)array[i2 * dimxy + j1 * dimx + k1] * KI1) * KJ2 +
((float)array[i1 * dimxy + j2 * dimx + k1] * KI2 +
(float)array[i2 * dimxy + j2 * dimx + k1] * KI1) * KJ1) * (k2-posx)+
(float)array[i2 * dimxy + j2 * dimx + k1] * KI1) * KJ1) * (float(k2)-posx)+
(((float)array[i1 * dimxy + j1 * dimx + k2] * KI2 +
(float)array[i2 * dimxy + j1 * dimx + k2] * KI1) * KJ2 +
((float)array[i1 * dimxy + j2 * dimx + k2] * KI2 +
(float)array[i2 * dimxy + j2 * dimx + k2] * KI1) * KJ1) * (posx-k1);
(float)array[i2 * dimxy + j2 * dimx + k2] * KI1) * KJ1) * (posx-float(k1));
);
return 0.f;
}
@ -1635,9 +1635,9 @@ void convertImageTypeToFloat(_image* image){
if(image->wordKind == WK_FLOAT && image->wdim == 4)
return;
const unsigned int dimx = image->xdim;
const unsigned int dimy = image->ydim;
const unsigned int dimz = image->zdim;
const std::size_t dimx = image->xdim;
const std::size_t dimy = image->ydim;
const std::size_t dimz = image->zdim;
float * array = (float*)ImageIO_alloc (dimx * dimy * dimz *sizeof(float));
if (array == NULL ) {

View File

@ -103,9 +103,9 @@ void Image_3::gl_draw_bbox(const float line_width,
double z() const { return z_; }
};
const double xmax = (image_ptr->xdim - 1.0)*(image_ptr->vx);
const double ymax = (image_ptr->ydim - 1.0)*(image_ptr->vy);
const double zmax = (image_ptr->zdim - 1.0)*(image_ptr->vz);
const double xmax = (double(image_ptr->xdim) - 1.0)*(image_ptr->vx);
const double ymax = (double(image_ptr->ydim) - 1.0)*(image_ptr->vy);
const double zmax = (double(image_ptr->zdim) - 1.0)*(image_ptr->vz);
Point a(0.0, 0.0, 0.0);
Point b(0.0, ymax, 0.0);

View File

@ -220,7 +220,7 @@ int testAnalyzeHeader(char *magic,const char *) {
CGAL_INLINE_FUNCTION
int writeAnalyze( char *name, _image* im) {
char *outputName;
int length, extLength=0, res;
std::size_t length, extLength=0;
length=strlen(name);
@ -252,7 +252,7 @@ int writeAnalyze( char *name, _image* im) {
return ImageIO_OPENING;
}
res = writeAnalyzeHeader(im);
int res = writeAnalyzeHeader(im);
if ( res < 0 ) {
fprintf(stderr, "writeAnalyze: error: unable to write header of \'%s\'\n",
outputName);
@ -530,7 +530,7 @@ int _readAnalyzeHeader( _image* im, const char* name,
/* header is read. close header file and open data file. */
if( name != NULL ) {
int length = strlen(name) ;
std::size_t length = strlen(name) ;
char* data_filename = (char *) ImageIO_alloc(length+4) ;
if( strcmp( name+length-4, ".hdr" ) )
@ -612,9 +612,9 @@ writeAnalyzeHeader( const _image* im )
hdr.dime.cal_min = 0.0;
hdr.dime.dim[0] = 4;
hdr.dime.dim[1] = im->xdim;
hdr.dime.dim[2] = im->ydim;
hdr.dime.dim[3] = im->zdim;
hdr.dime.dim[1] = short(im->xdim);
hdr.dime.dim[2] = short(im->ydim);
hdr.dime.dim[3] = short(im->zdim);
hdr.dime.dim[4] = 1 ;
if ( im->wordKind == WK_FIXED && im->sign == SGN_UNSIGNED ) {
@ -633,9 +633,9 @@ writeAnalyzeHeader( const _image* im )
{
unsigned char *buf = (unsigned char *)im->data;
int size = im->xdim * im->ydim * im->zdim * im->vdim;
std::size_t size = std::size_t(im->xdim) * im->ydim * im->zdim * im->vdim;
imin = imax = *buf;
for (i=0; i<size; i++, buf++) {
for (std::size_t i=0; i<size; i++, buf++) {
if ( imax < *buf ) imax = *buf;
if ( imin > *buf ) imin = *buf;
}
@ -645,10 +645,9 @@ writeAnalyzeHeader( const _image* im )
else if ( im->wdim == 2 ) {
if ( im->vdim == 1 ) {
unsigned short int *buf = (unsigned short int*)im->data;
int size = im->xdim * im->ydim *im->zdim;
int i;
std::size_t size = std::size_t(im->xdim) * im->ydim *im->zdim;
imin = imax = *buf;
for (i=0; i<size; i++, buf++) {
for (std::size_t i=0; i<size; i++, buf++) {
if ( imax < *buf ) imax = *buf;
if ( imin > *buf ) imin = *buf;
}
@ -680,10 +679,9 @@ writeAnalyzeHeader( const _image* im )
}
if( im->wdim == 2 ) {
short int *buf = (short int*)im->data;
int size = im->xdim * im->ydim *im->zdim;
int i;
std::size_t size = std::size_t(im->xdim) * im->ydim *im->zdim;
imin = imax = *buf;
for (i=0; i<size; i++, buf++) {
for (std::size_t i=0; i<size; i++, buf++) {
if ( imax < *buf ) imax = *buf;
if ( imin > *buf ) imin = *buf;
}
@ -691,10 +689,9 @@ writeAnalyzeHeader( const _image* im )
}
else if( im->wdim == 4 ) {
int *buf = (int*)im->data;
int size = im->xdim * im->ydim *im->zdim;
int i;
std::size_t size = std::size_t(im->xdim) * im->ydim *im->zdim;
imin = imax = *buf;
for (i=0; i<size; i++, buf++) {
for (std::size_t i=0; i<size; i++, buf++) {
if ( imax < *buf ) imax = *buf;
if ( imin > *buf ) imin = *buf;
}
@ -727,7 +724,7 @@ writeAnalyzeHeader( const _image* im )
return -1;
}
hdr.dime.bitpix = 8*im->wdim*im->vdim ;
hdr.dime.bitpix = short(8*im->wdim*im->vdim) ;
hdr.hk.regular = 'r';
hdr.hk.sizeof_hdr = sizeof(struct dsr);

View File

@ -341,8 +341,8 @@ void *_readBmpImage( const char *name,
myBuf[i+2] = argbs[0][row * widths[0] + col].blue;
}
*dimx = widths[0];
*dimy = heights[0];
*dimx = int(widths[0]);
*dimy = int(heights[0]);
*dimz = 3;
} else {

View File

@ -57,7 +57,7 @@ int readINT8little(FILE *f, CGAL_INT8 *i)
if (rc == EOF)
return rc;
*i = (rc & 0xff);
*i = CGAL_INT8(rc & 0xff);
return 0;
}
@ -70,7 +70,7 @@ int readUINT8little(FILE *f, CGAL_UINT8 *i)
if (rc == EOF)
return rc;
*i = (rc & 0xff);
*i = CGAL_UINT8(rc & 0xff);
return 0;
}
@ -92,7 +92,7 @@ int readINT16little(FILE *f, CGAL_INT16 *i)
if (rc == EOF)
return rc;
temp |= ((rc & 0xff) << 8);
temp = temp | CGAL_INT16((rc & 0xff) << 8);
*i = temp;
return 0;
}
@ -109,7 +109,7 @@ int readUINT16little(FILE *f, CGAL_UINT16 *i)
if (rc == EOF)
return rc;
temp |= ((rc & 0xff) << 8);
temp = CGAL_INT16(temp | ((rc & 0xff) << 8));
*i = temp;
return 0;
}
@ -126,14 +126,14 @@ int readINT32little(FILE *f, CGAL_INT32 *i)
CGAL_INT32 temp = 0;
temp = ((long)fgetc(f) & 0xff);
temp |= (((long)fgetc(f) & 0xff) << 8);
temp |= (((long)fgetc(f) & 0xff) << 16);
temp = CGAL_INT32(temp | (((long)fgetc(f) & 0xff) << 8));
temp = CGAL_INT32(temp | (((long)fgetc(f) & 0xff) << 16));
rc = fgetc(f);
if (rc == EOF)
return rc;
temp |= (((long)rc & 0xff) << 24);
temp = CGAL_INT32(temp | (((long)rc & 0xff) << 24));
*i = temp;
return 0;
}
@ -145,14 +145,14 @@ int readUINT32little(FILE *f, CGAL_UINT32 *i)
CGAL_UINT32 temp = 0;
temp = ((long)fgetc(f) & 0xff);
temp |= (((long)fgetc(f) & 0xff) << 8);
temp |= (((long)fgetc(f) & 0xff) << 16);
temp = CGAL_UINT32(temp | (((long)fgetc(f) & 0xff) << 8));
temp = CGAL_UINT32(temp | (((long)fgetc(f) & 0xff) << 16));
rc = fgetc(f);
if (rc == EOF)
return rc;
temp |= (((long)rc & 0xff) << 24);
temp = CGAL_UINT32(temp | (((long)rc & 0xff) << 24));
*i = temp;
return 0;
}

View File

@ -743,7 +743,8 @@ int readSingleImageBMP(FILE *fp, RGB **argb, CGAL_UINT32 *width, CGAL_UINT32 *he
RGB *colorTable = (RGB*)NULL;
RGB *image = (RGB*)NULL;
int rc, depth, inverted;
long numColors, numPixels, endPos;
int numColors;
long numPixels, endPos;
/*
* First, get the file header and sanity check it. The type field must be

View File

@ -44,12 +44,14 @@
* CGAL_UINT32 is an unsigned CGAL_INT32
*/
#include <boost/cstdint.hpp>
typedef char CGAL_INT8;
typedef short CGAL_INT16;
typedef long CGAL_INT32;
typedef boost::int32_t CGAL_INT32;
typedef unsigned char CGAL_UINT8;
typedef unsigned short CGAL_UINT16;
typedef unsigned long CGAL_UINT32;
typedef boost::uint32_t CGAL_UINT32;
/*****************************************************************************
*

View File

@ -55,7 +55,7 @@ void ConvertBuffer( void *bufferIn,
int bufferLength )
{
const char *proc = "ConvertBuffer";
int i, min, max;
int i;
u8 *u8buf;
s8 *s8buf;
u16 *u16buf;
@ -79,9 +79,9 @@ void ConvertBuffer( void *bufferIn,
}
switch ( typeOut ) {
case CGAL_SCHAR :
case CGAL_SCHAR : {
s8buf = (s8*)bufferOut;
min = -128; max = 127;
s8 min = -128, max = 127;
switch( typeIn ) {
case CGAL_SCHAR :
if ( bufferOut == bufferIn ) return;
@ -91,8 +91,8 @@ void ConvertBuffer( void *bufferIn,
r32buf = (r32*)bufferIn;
for (i=bufferLength; i>0; i--, s8buf++, r32buf++ ) {
if ( *r32buf < min ) *s8buf = min;
else if ( *r32buf < 0.0 ) *s8buf = (int)(*r32buf - 0.5);
else if ( *r32buf < max ) *s8buf = (int)(*r32buf + 0.5);
else if ( *r32buf < 0.0 ) *s8buf = (s8)(*r32buf - 0.5);
else if ( *r32buf < max ) *s8buf = (s8)(*r32buf + 0.5);
else *s8buf = max;
}
break;
@ -100,8 +100,8 @@ void ConvertBuffer( void *bufferIn,
r64buf = (r64*)bufferIn;
for (i=bufferLength; i>0; i--, s8buf++, r64buf++ ) {
if ( *r64buf < min ) *s8buf = min;
else if ( *r64buf < 0.0 ) *s8buf = (int)(*r64buf - 0.5);
else if ( *r64buf < max ) *s8buf = (int)(*r64buf + 0.5);
else if ( *r64buf < 0.0 ) *s8buf = (s8)(*r64buf - 0.5);
else if ( *r64buf < max ) *s8buf = (s8)(*r64buf + 0.5);
else *s8buf = max;
}
break;
@ -111,14 +111,14 @@ void ConvertBuffer( void *bufferIn,
return;
}
break; /* end case typeOut = CGAL_SCHAR */
}
case CGAL_UCHAR :
case CGAL_UCHAR : {
u8buf = (u8*)bufferOut;
min = 0; max = 255;
u8 min = 0, max = 255;
switch( typeIn ) {
case CGAL_UCHAR :
if ( bufferOut == bufferIn ) return;
@ -135,7 +135,7 @@ void ConvertBuffer( void *bufferIn,
r32buf = (r32*)bufferIn;
for (i=bufferLength; i>0; i--, u8buf++, r32buf++ ) {
if ( *r32buf < min ) *u8buf = min;
else if ( *r32buf < max ) *u8buf = (int)(*r32buf + 0.5);
else if ( *r32buf < max ) *u8buf = (u8)(*r32buf + 0.5);
else *u8buf = max;
}
break;
@ -143,7 +143,7 @@ void ConvertBuffer( void *bufferIn,
r64buf = (r64*)bufferIn;
for (i=bufferLength; i>0; i--, u8buf++, r64buf++ ) {
if ( *r64buf < min ) *u8buf = min;
else if ( *r64buf < max ) *u8buf = (int)(*r64buf + 0.5);
else if ( *r64buf < max ) *u8buf = (u8)(*r64buf + 0.5);
else *u8buf = max;
}
break;
@ -153,15 +153,15 @@ void ConvertBuffer( void *bufferIn,
return;
}
break; /* end case typeOut = CGAL_UCHAR */
}
case CGAL_SSHORT :
case CGAL_SSHORT : {
s16buf = (s16*)bufferOut;
min = -32768; max = 32767;
s16 min = -32768, max = 32767;
switch( typeIn ) {
case CGAL_SSHORT :
if ( bufferOut == bufferIn ) return;
@ -178,8 +178,8 @@ void ConvertBuffer( void *bufferIn,
r32buf = (r32*)bufferIn;
for (i=bufferLength; i>0; i--, s16buf++, r32buf++ ) {
if ( *r32buf < min ) *s16buf = min;
else if ( *r32buf < 0.0 ) *s16buf = (int)(*r32buf - 0.5);
else if ( *r32buf < max ) *s16buf = (int)(*r32buf + 0.5);
else if ( *r32buf < 0.0 ) *s16buf = (s16)(*r32buf - 0.5);
else if ( *r32buf < max ) *s16buf = (s16)(*r32buf + 0.5);
else *s16buf = max;
}
break;
@ -187,8 +187,8 @@ void ConvertBuffer( void *bufferIn,
r64buf = (r64*)bufferIn;
for (i=bufferLength; i>0; i--, s16buf++, r64buf++ ) {
if ( *r64buf < min ) *s16buf = min;
else if ( *r64buf < 0.0 ) *s16buf = (int)(*r64buf - 0.5);
else if ( *r64buf < max ) *s16buf = (int)(*r64buf + 0.5);
else if ( *r64buf < 0.0 ) *s16buf = (s16)(*r64buf - 0.5);
else if ( *r64buf < max ) *s16buf = (s16)(*r64buf + 0.5);
else *s16buf = max;
}
break;
@ -198,14 +198,14 @@ void ConvertBuffer( void *bufferIn,
return;
}
break; /* end case typeOut = CGAL_SSHORT */
}
case CGAL_USHORT :
case CGAL_USHORT : {
u16buf = (u16*)bufferOut;
min = 0; max = 65535;
u16 min = 0, max = 65535;
switch( typeIn ) {
case CGAL_USHORT :
if ( bufferOut == bufferIn ) return;
@ -215,8 +215,8 @@ void ConvertBuffer( void *bufferIn,
r32buf = (r32*)bufferIn;
for (i=bufferLength; i>0; i--, u16buf++, r32buf++ ) {
if ( *r32buf < min ) *u16buf = min;
else if ( *r32buf < 0.0 ) *u16buf = (int)(*r32buf - 0.5);
else if ( *r32buf < max ) *u16buf = (int)(*r32buf + 0.5);
else if ( *r32buf < 0.0 ) *u16buf = (u16)(*r32buf - 0.5);
else if ( *r32buf < max ) *u16buf = (u16)(*r32buf + 0.5);
else *u16buf = max;
}
break;
@ -224,8 +224,8 @@ void ConvertBuffer( void *bufferIn,
r64buf = (r64*)bufferIn;
for (i=bufferLength; i>0; i--, u16buf++, r64buf++ ) {
if ( *r64buf < min ) *u16buf = min;
else if ( *r64buf < 0.0 ) *u16buf = (int)(*r64buf - 0.5);
else if ( *r64buf < max ) *u16buf = (int)(*r64buf + 0.5);
else if ( *r64buf < 0.0 ) *u16buf = (u16)(*r64buf - 0.5);
else if ( *r64buf < max ) *u16buf = (u16)(*r64buf + 0.5);
else *u16buf = max;
}
break;
@ -235,7 +235,7 @@ void ConvertBuffer( void *bufferIn,
return;
}
break; /* end case typeOut = CGAL_USHORT */
}
@ -403,9 +403,9 @@ void Convert_r32_to_s8( r32 *theBuf,
if ( *tb < -128.0 ) {
*rb = -128;
} else if ( *tb < 0.0 ) {
*rb = (int)(*tb - 0.5);
*rb = (s8)(*tb - 0.5);
} else if ( *tb < 127.0 ) {
*rb = (int)(*tb + 0.5);
*rb = (s8)(*tb + 0.5);
} else {
*rb = 127;
}
@ -429,7 +429,7 @@ void Convert_r32_to_u8( r32 *theBuf,
if ( *tb < 0.0 ) {
*rb = 0;
} else if ( *tb < 255.0 ) {
*rb = (int)(*tb + 0.5);
*rb = (u8)(*tb + 0.5);
} else {
*rb = 255;
}
@ -453,9 +453,9 @@ void Convert_r32_to_s16( r32 *theBuf,
if ( *tb < -32768.0 ) {
*rb = -32768;
} else if ( *tb < 0.0 ) {
*rb = (int)(*tb - 0.5);
*rb = (s16)(*tb - 0.5);
} else if ( *tb < 32767.0 ) {
*rb = (int)(*tb + 0.5);
*rb = (s16)(*tb + 0.5);
} else {
*rb = 32767;
}
@ -479,7 +479,7 @@ void Convert_r32_to_u16( r32 *theBuf,
if ( *tb < 0.0 ) {
*rb = 0;
} else if ( *tb < 65535.0 ) {
*rb = (int)(*tb + 0.5);
*rb = (u16)(*tb + 0.5);
} else {
*rb = 65535;
}

View File

@ -31,15 +31,12 @@
if any */
CGAL_INLINE_FUNCTION
char *fgetns(char *str, int n, _image *im ) {
char *ret;
int l;
memset( str, 0, n );
ret = ImageIO_gets( im, str, n );
char* ret = ImageIO_gets( im, str, n );
if(!ret) return NULL;
l = strlen(str);
std::size_t l = strlen(str);
if(l > 0 && str[l-1] == '\n') str[l-1] = '\0';
return ret;
}

View File

@ -255,9 +255,9 @@ int gif89 = 0;
get_static_b() = (byte *) ImageIO_alloc(256 * sizeof(byte));
for (i = 0; i < 256; i++) {
get_static_r()[i] = EGApalette[i&15][0];
get_static_g()[i] = EGApalette[i&15][1];
get_static_b()[i] = EGApalette[i&15][2];
get_static_r()[i] = byte(EGApalette[i&15][0]);
get_static_g()[i] = byte(EGApalette[i&15][1]);
get_static_b()[i] = byte(EGApalette[i&15][2]);
}
}

View File

@ -48,8 +48,9 @@ PTRIMAGE_FORMAT createGisFormat() {
CGAL_INLINE_FUNCTION
int writeGis( char *name, _image* im) {
char *outputName;
int length, extLength=0, res;
std::size_t length, extLength=0;
int res;
std::size_t done;
length=strlen(name);
outputName= (char *)ImageIO_alloc(length+8);
@ -110,7 +111,7 @@ int writeGis( char *name, _image* im) {
}
if ( im->dataMode == DM_ASCII ) {
int i, j, n, size;
std::size_t i, j, n, size;
char *str = (char*)ImageIO_alloc( _LGTH_STRING_+1 );
size = im->xdim * im->ydim * im->zdim * im->vdim;
n = ( im->xdim < 16 ) ? im->xdim : 16;
@ -143,7 +144,8 @@ int writeGis( char *name, _image* im) {
if ( j<n && i<size ) sprintf( str+strlen(str), " " );
}
sprintf( str+strlen(str), "\n" );
res = ImageIO_write( im, str, strlen( str ) );
done = ImageIO_write( im, str, strlen( str ) );
res = (done == strlen( str )) ? int(done) : -1;
if ( res <= 0 ) {
fprintf(stderr, "writeGis: error when writing data in \'%s\'\n", outputName);
if ( outputName != NULL ) ImageIO_free( outputName );
@ -162,7 +164,8 @@ int writeGis( char *name, _image* im) {
if ( j<n && i<size ) sprintf( str+strlen(str), " " );
}
sprintf( str+strlen(str), "\n" );
res = ImageIO_write( im, str, strlen( str ) );
done = ImageIO_write( im, str, strlen( str ) );
res = (done == strlen( str )) ? int(done) : -1;
if ( res <= 0 ) {
fprintf(stderr, "writeGis: error when writing data in \'%s\'\n", outputName);
if ( outputName != NULL ) ImageIO_free( outputName );
@ -189,7 +192,8 @@ int writeGis( char *name, _image* im) {
if ( j<n && i<size ) sprintf( str+strlen(str), " " );
}
sprintf( str+strlen(str), "\n" );
res = ImageIO_write( im, str, strlen( str ) );
done = ImageIO_write( im, str, strlen( str ) );
res = (done == strlen( str )) ? int(done) : -1;
if ( res <= 0 ) {
fprintf(stderr, "writeGis: error when writing data in \'%s\'\n", outputName);
if ( outputName != NULL ) ImageIO_free( outputName );
@ -208,7 +212,8 @@ int writeGis( char *name, _image* im) {
if ( j<n && i<size ) sprintf( str+strlen(str), " " );
}
sprintf( str+strlen(str), "\n" );
res = ImageIO_write( im, str, strlen( str ) );
done = ImageIO_write( im, str, strlen( str ) );
res = (done == strlen( str )) ? int(done) : -1;
if ( res <= 0 ) {
fprintf(stderr, "writeGis: error when writing data in \'%s\'\n", outputName);
if ( outputName != NULL ) ImageIO_free( outputName );
@ -261,7 +266,7 @@ int readGisHeader( const char* name,_image* im)
iss.str(str);
iss >> im->xdim >> im->ydim >> im->zdim >> im->vdim;
status = iss.str().length();
status = (int)iss.str().length();
switch ( status ) {
case 2 : im->zdim = 1;
case 3 : im->vdim = 1;
@ -468,7 +473,7 @@ int readGisHeader( const char* name,_image* im)
/* header is read. close header file and open data file. */
if( name != NULL ) {
int length = strlen(name) ;
std::size_t length = strlen(name) ;
char* data_filename = (char *) ImageIO_alloc(length+4) ;
if( strcmp( name+length-4, ".dim" ) ) {
@ -510,7 +515,7 @@ int readGisHeader( const char* name,_image* im)
only U8 and S8
*/
if ( im->dataMode == DM_ASCII ) {
int size = im->xdim * im->ydim * im->zdim * im->vdim * im->wdim;
std::size_t size = std::size_t(im->xdim) * im->ydim * im->zdim * im->vdim * im->wdim;
unsigned int n;
char *tmp;
int ret, iv=0;

View File

@ -139,7 +139,7 @@ static void expandrow(byte *optr, byte *iptr, int z)
optr[7*4] = iptr[7];
optr += 8*4;
iptr += 8;
count -= 8;
count = byte(count - 8);
}
while(count--) {
*optr = *iptr++;
@ -158,7 +158,7 @@ static void expandrow(byte *optr, byte *iptr, int z)
optr[6*4] = pixel;
optr[7*4] = pixel;
optr += 8*4;
count -= 8;
count = byte(count - 8);
}
while(count--) {
*optr = pixel;
@ -194,16 +194,16 @@ static void addimgtag(byte *dptr, int xsize, int ysize)
dptr[0] = 0x69; dptr[1] = 0x43; dptr[2] = 0x42; dptr[3] = 0x22;
dptr += 4;
dptr[0] = (xsize>>24)&0xff;
dptr[1] = (xsize>>16)&0xff;
dptr[2] = (xsize>> 8)&0xff;
dptr[3] = (xsize )&0xff;
dptr[0] = byte((xsize>>24)&0xff);
dptr[1] = byte((xsize>>16)&0xff);
dptr[2] = byte((xsize>> 8)&0xff);
dptr[3] = byte((xsize )&0xff);
dptr += 4;
dptr[0] = (ysize>>24)&0xff;
dptr[1] = (ysize>>16)&0xff;
dptr[2] = (ysize>> 8)&0xff;
dptr[3] = (ysize )&0xff;
dptr[0] = byte((ysize>>24)&0xff);
dptr[1] = byte((ysize>>16)&0xff);
dptr[2] = byte((ysize>> 8)&0xff);
dptr[3] = byte((ysize )&0xff);
}
/* byte order independent read/write of shorts and longs. */
@ -212,7 +212,7 @@ static unsigned short getshort( const _image *im)
{
byte buf[2];
ImageIO_read( im, buf, (size_t) 2);
return (buf[0]<<8)+(buf[1]<<0);
return (unsigned short)((buf[0]<<8)+(buf[1]<<0));
}
/*****************************************************/
@ -229,9 +229,9 @@ CGAL_INLINE_FUNCTION
int readIrisImage( const char *, _image *im ) {
byte *rawdata, *rptr;
byte *pic824, *bptr, *iptr;
int i, j, size;
std::size_t i, j, size;
unsigned short imagic, type;
int xsize, ysize, zsize;
unsigned int xsize, ysize, zsize;
/* read header information from file */
@ -277,10 +277,10 @@ int readIrisImage( const char *, _image *im ) {
if (!pic824) exit(-1);
/* copy plane 3 from rawdata into pic824, inverting pic vertically */
for (i = 0, bptr = pic824; i < (int) ysize; i++)
for (i = 0, bptr = pic824; i < ysize; i++)
{
rptr = rawdata + 3 + ((ysize - 1) - i) * (xsize * 4);
for (j = 0; j < (int) xsize; j++, bptr++, rptr += 4)
for (j = 0; j < xsize; j++, bptr++, rptr += 4)
*bptr = *rptr;
}
@ -311,11 +311,11 @@ int readIrisImage( const char *, _image *im ) {
exit(1);
/* copy plane 3 from rawdata into pic824, inverting pic vertically */
for (i = 0, bptr = pic824; i<(int) ysize; i++)
for (i = 0, bptr = pic824; i< ysize; i++)
{
rptr = rawdata + ((ysize - 1) - i) * (xsize * 4);
for (j=0; j<(int) xsize; j++, rptr += 4) {
for (j=0; j< xsize; j++, rptr += 4) {
*bptr++ = rptr[3];
*bptr++ = rptr[2];
*bptr++ = rptr[1];