Lines 34-39
Link Here
|
34 |
# include <unistd.h> |
34 |
# include <unistd.h> |
35 |
#endif |
35 |
#endif |
36 |
|
36 |
|
|
|
37 |
#include "tiffiop.h" |
37 |
#include "tiffio.h" |
38 |
#include "tiffio.h" |
38 |
|
39 |
|
39 |
#define streq(a,b) (strcmp(a,b) == 0) |
40 |
#define streq(a,b) (strcmp(a,b) == 0) |
Lines 328-343
cvt_whole_image( TIFF *in, TIFF *out )
Link Here
|
328 |
uint32* raster; /* retrieve RGBA image */ |
329 |
uint32* raster; /* retrieve RGBA image */ |
329 |
uint32 width, height; /* image width & height */ |
330 |
uint32 width, height; /* image width & height */ |
330 |
uint32 row; |
331 |
uint32 row; |
|
|
332 |
size_t pixel_count; |
331 |
|
333 |
|
332 |
TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); |
334 |
TIFFGetField(in, TIFFTAG_IMAGEWIDTH, &width); |
333 |
TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); |
335 |
TIFFGetField(in, TIFFTAG_IMAGELENGTH, &height); |
|
|
336 |
pixel_count = width * height; |
337 |
|
338 |
/* XXX: Check the integer overflow. */ |
339 |
if (!width || !height || pixel_count / width != height) { |
340 |
TIFFError(TIFFFileName(in), |
341 |
"Malformed input file; can't allocate buffer for raster of %lux%lu size", |
342 |
(unsigned long)width, (unsigned long)height); |
343 |
return 0; |
344 |
} |
334 |
|
345 |
|
335 |
rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); |
346 |
rowsperstrip = TIFFDefaultStripSize(out, rowsperstrip); |
336 |
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); |
347 |
TIFFSetField(out, TIFFTAG_ROWSPERSTRIP, rowsperstrip); |
337 |
|
348 |
|
338 |
raster = (uint32*)_TIFFmalloc(width * height * sizeof (uint32)); |
349 |
raster = (uint32*)_TIFFCheckMalloc(in, pixel_count, sizeof(uint32), "raster buffer"); |
339 |
if (raster == 0) { |
350 |
if (raster == 0) { |
340 |
TIFFError(TIFFFileName(in), "No space for raster buffer"); |
351 |
TIFFError(TIFFFileName(in), "Requested buffer size is %lu elements %lu each", |
|
|
352 |
(unsigned long)pixel_count, (unsigned long)sizeof(uint32)); |
341 |
return (0); |
353 |
return (0); |
342 |
} |
354 |
} |
343 |
|
355 |
|
Lines 353-370
cvt_whole_image( TIFF *in, TIFF *out )
Link Here
|
353 |
*/ |
365 |
*/ |
354 |
if( no_alpha ) |
366 |
if( no_alpha ) |
355 |
{ |
367 |
{ |
356 |
int pixel_count = width * height; |
368 |
size_t count = pixel_count; |
357 |
unsigned char *src, *dst; |
369 |
unsigned char *src, *dst; |
358 |
|
370 |
|
359 |
src = (unsigned char *) raster; |
371 |
src = (unsigned char *) raster; |
360 |
dst = (unsigned char *) raster; |
372 |
dst = (unsigned char *) raster; |
361 |
while( pixel_count > 0 ) |
373 |
while(count > 0) |
362 |
{ |
374 |
{ |
363 |
*(dst++) = *(src++); |
375 |
*(dst++) = *(src++); |
364 |
*(dst++) = *(src++); |
376 |
*(dst++) = *(src++); |
365 |
*(dst++) = *(src++); |
377 |
*(dst++) = *(src++); |
366 |
src++; |
378 |
src++; |
367 |
pixel_count--; |
379 |
count--; |
368 |
} |
380 |
} |
369 |
} |
381 |
} |
370 |
|
382 |
|