+#define IMAGER_NO_CONTEXT
#include <stdarg.h>
#include "imageri.h"
*/
int
i_writebmp_wiol(i_img *im, io_glue *ig) {
+ dIMCTXim(im);
i_clear_error();
/* pick a format */
i_packed_t xsize, ysize, planes, bit_count, compression, size_image, xres, yres;
i_packed_t clr_used, clr_important, offbits;
i_img *im;
+ dIMCTXio(ig);
- mm_log((1, "i_readbmp_wiol(ig %p)\n", ig));
+ im_log((aIMCTX, 1, "i_readbmp_wiol(ig %p)\n", ig));
i_clear_error();
return 0;
}
- mm_log((1, " bmp header: filesize %d offbits %d xsize %d ysize %d planes %d "
+ im_log((aIMCTX, 1, " bmp header: filesize %d offbits %d xsize %d ysize %d planes %d "
"bit_count %d compression %d size %d xres %d yres %d clr_used %d "
"clr_important %d\n", (int)filesize, (int)offbits, (int)xsize,
(int)ysize, (int)planes, (int)bit_count, (int)compression,
(int)clr_important));
if (!i_int_check_image_file_limits(xsize, abs(ysize), 3, sizeof(i_sample_t))) {
- mm_log((1, "i_readbmp_wiol: image size exceeds limits\n"));
+ im_log((aIMCTX, 1, "i_readbmp_wiol: image size exceeds limits\n"));
return NULL;
}
break;
default:
- i_push_errorf(0, "unknown bit count for BMP file (%d)", (int)bit_count);
+ im_push_errorf(aIMCTX, 0, "unknown bit count for BMP file (%d)", (int)bit_count);
return NULL;
}
break;
default:
- i_fatal(1, "Unknown read_packed format code 0x%02x", code);
+ {
+ dIMCTXio(ig);
+ im_fatal(aIMCTX, 1, "Unknown read_packed format code 0x%02x", code);
+ }
}
}
return 1;
break;
default:
- i_fatal(1, "Unknown write_packed format code 0x%02x", *format);
+ {
+ dIMCTXio(ig);
+ im_fatal(aIMCTX, 1, "Unknown write_packed format code 0x%02x", *format);
+ }
}
++format;
}
int got_xres, got_yres, aspect_only;
int colors_used = 0;
int offset = FILEHEAD_SIZE + INFOHEAD_SIZE;
+ dIMCTXim(im);
if (im->xsize > SIGNMAX32 || im->ysize > SIGNMAX32) {
i_push_error(0, "image too large to write to BMP");
int line_size = (im->xsize+7) / 8;
int x, y;
int unpacked_size;
+ dIMCTXim(im);
/* round up to nearest multiple of four */
line_size = (line_size + 3) / 4 * 4;
int line_size = (im->xsize+1) / 2;
int x, y;
int unpacked_size;
+ dIMCTXim(im);
/* round up to nearest multiple of four */
line_size = (line_size + 3) / 4 * 4;
int line_size = im->xsize;
int y;
int unpacked_size;
+ dIMCTXim(im);
/* round up to nearest multiple of four */
line_size = (line_size + 3) / 4 * 4;
int y;
int line_size = 3 * im->xsize;
i_color bg;
+ dIMCTXim(im);
i_get_file_background(im, &bg);
int i;
i_packed_t r, g, b, x;
i_color c;
+ dIMCTXio(ig);
for (i = 0; i < count; ++i) {
if (!read_packed(ig, "CCCC", &b, &g, &r, &x)) {
int bit;
unsigned char *in;
long base_offset;
+ dIMCTXio(ig);
if (compression != BI_RGB) {
- i_push_errorf(0, "unknown 1-bit BMP compression (%d)", compression);
+ im_push_errorf(aIMCTX, 0, "unknown 1-bit BMP compression (%d)", compression);
return NULL;
}
if (!clr_used)
clr_used = 2;
if (clr_used < 0 || clr_used > 2) {
- i_push_errorf(0, "out of range colors used (%d)", clr_used);
+ im_push_errorf(aIMCTX, 0, "out of range colors used (%d)", clr_used);
return NULL;
}
base_offset = FILEHEAD_SIZE + INFOHEAD_SIZE + clr_used * 4;
if (offbits < base_offset) {
- i_push_errorf(0, "image data offset too small (%ld)", offbits);
+ im_push_errorf(aIMCTX, 0, "image data offset too small (%ld)", offbits);
return NULL;
}
int size, i;
long base_offset;
int starty;
+ dIMCTXio(ig);
/* line_size is going to be smaller than xsize in most cases (and
when it's not, xsize is itself small), and hence not overflow */
clr_used = 16;
if (clr_used > 16 || clr_used < 0) {
- i_push_errorf(0, "out of range colors used (%d)", clr_used);
+ im_push_errorf(aIMCTX, 0, "out of range colors used (%d)", clr_used);
return NULL;
}
base_offset = FILEHEAD_SIZE + INFOHEAD_SIZE + clr_used * 4;
if (offbits < base_offset) {
- i_push_errorf(0, "image data offset too small (%ld)", offbits);
+ im_push_errorf(aIMCTX, 0, "image data offset too small (%ld)", offbits);
return NULL;
}
myfree(packed);
myfree(line);
i_push_error(0, "invalid data during decompression");
- mm_log((1, "read 4-bit: scanline overflow x %d + count %d vs xlimit %d (y %d)\n",
+ im_log((aIMCTX, 1, "read 4-bit: scanline overflow x %d + count %d vs xlimit %d (y %d)\n",
(int)x, count, (int)xlimit, (int)y));
i_img_destroy(im);
return NULL;
myfree(packed);
myfree(line);
i_push_error(0, "invalid data during decompression");
- mm_log((1, "read 4-bit: scanline overflow (unpacked) x %d + count %d vs xlimit %d (y %d)\n",
+ im_log((aIMCTX, 1, "read 4-bit: scanline overflow (unpacked) x %d + count %d vs xlimit %d (y %d)\n",
(int)x, count, (int)xlimit, (int)y));
i_img_destroy(im);
return NULL;
else { /*if (compression == BI_RLE4) {*/
myfree(packed);
myfree(line);
- i_push_errorf(0, "unknown 4-bit BMP compression (%d)", compression);
+ im_push_errorf(aIMCTX, 0, "unknown 4-bit BMP compression (%d)", compression);
i_img_destroy(im);
return NULL;
}
i_palidx *line;
int line_size = xsize;
long base_offset;
+ dIMCTXio(ig);
line_size = (line_size+3) / 4 * 4;
if (line_size < xsize) { /* if it overflowed (unlikely, but check) */
if (!clr_used)
clr_used = 256;
if (clr_used > 256 || clr_used < 0) {
- i_push_errorf(0, "out of range colors used (%d)", clr_used);
+ im_push_errorf(aIMCTX, 0, "out of range colors used (%d)", clr_used);
return NULL;
}
base_offset = FILEHEAD_SIZE + INFOHEAD_SIZE + clr_used * 4;
if (offbits < base_offset) {
- i_push_errorf(0, "image data offset too small (%ld)", offbits);
+ im_push_errorf(aIMCTX, 0, "image data offset too small (%ld)", offbits);
return NULL;
}
}
else {
myfree(line);
- i_push_errorf(0, "unknown 8-bit BMP compression (%d)", compression);
+ im_push_errorf(aIMCTX, 0, "unknown 8-bit BMP compression (%d)", compression);
i_img_destroy(im);
return NULL;
}
const char *compression_name;
int bytes;
long base_offset = FILEHEAD_SIZE + INFOHEAD_SIZE;
+ dIMCTXio(ig);
unpack_code[0] = *("v3V"+pix_size-2);
unpack_code[1] = '\0';
return 0;
}
if (rmask == 0) {
- i_push_errorf(0, "Zero mask for channel %d", i);
+ im_push_errorf(aIMCTX, 0, "Zero mask for channel %d", i);
return NULL;
}
masks.masks[i] = rmask;
base_offset += 3 * 4;
}
else {
- i_push_errorf(0, "unknown 24-bit BMP compression (%d)", compression);
+ im_push_errorf(aIMCTX, 0, "unknown 24-bit BMP compression (%d)", compression);
return NULL;
}
if (offbits < base_offset) {
- i_push_errorf(0, "image data offset too small (%ld)", offbits);
+ im_push_errorf(aIMCTX, 0, "image data offset too small (%ld)", offbits);
return NULL;
}