mm_log((1,"i_readsgi(ig %p, partial %d)\n", ig, partial));
i_clear_error();
- if (ig->readcb(ig, headbuf, 512) != 512) {
+ if (i_io_read(ig, headbuf, 512) != 512) {
i_push_error(errno, "SGI image: could not read header");
return NULL;
}
for(y = 0; y < height; y++) {
int x;
- if (ig->readcb(ig, databuf, width) != width) {
+ if (i_io_read(ig, databuf, width) != width) {
i_push_error(0, "SGI image: cannot read image data");
i_img_destroy(img);
myfree(linebuf);
length_tab = mymalloc(height*channels*sizeof(unsigned long));
/* Read offset table */
- if (ig->readcb(ig, databuf, height * channels * 4) != height * channels * 4) {
+ if (i_io_read(ig, databuf, height * channels * 4) != height * channels * 4) {
i_push_error(0, "SGI image: short read reading RLE start table");
goto ErrorReturn;
}
/* Read length table */
- if (ig->readcb(ig, databuf, height*channels*4) != height*channels*4) {
+ if (i_io_read(ig, databuf, height*channels*4) != height*channels*4) {
i_push_error(0, "SGI image: short read reading RLE length table");
goto ErrorReturn;
}
int pixels_left = width;
i_sample_t sample;
- if (ig->seekcb(ig, start_tab[ci], SEEK_SET) != start_tab[ci]) {
+ if (i_io_seek(ig, start_tab[ci], SEEK_SET) != start_tab[ci]) {
i_push_error(0, "SGI image: cannot seek to RLE data");
goto ErrorReturn;
}
- if (ig->readcb(ig, databuf, datalen) != datalen) {
+ if (i_io_read(ig, databuf, datalen) != datalen) {
i_push_error(0, "SGI image: cannot read RLE data");
goto ErrorReturn;
}
for(y = 0; y < height; y++) {
int x;
- if (ig->readcb(ig, databuf, width*2) != width*2) {
+ if (i_io_read(ig, databuf, width*2) != width*2) {
i_push_error(0, "SGI image: cannot read image data");
i_img_destroy(img);
myfree(linebuf);
i_push_error(0, "SGI image: invalid RLE length value for BPC=2");
goto ErrorReturn;
}
- if (ig->seekcb(ig, start_tab[ci], SEEK_SET) != start_tab[ci]) {
+ if (i_io_seek(ig, start_tab[ci], SEEK_SET) != start_tab[ci]) {
i_push_error(0, "SGI image: cannot seek to RLE data");
goto ErrorReturn;
}
- if (ig->readcb(ig, databuf, datalen) != datalen) {
+ if (i_io_read(ig, databuf, datalen) != datalen) {
i_push_error(0, "SGI image: cannot read RLE data");
goto ErrorReturn;
}
for (c = 0; c < img->channels; ++c) {
for (y = img->ysize - 1; y >= 0; --y) {
i_gsamp(img, 0, width, y, linebuf, &c, 1);
- if (ig->writecb(ig, linebuf, width) != width) {
+ if (i_io_write(ig, linebuf, width) != width) {
i_push_error(errno, "SGI image: error writing image data");
myfree(linebuf);
return 0;
}
myfree(linebuf);
+ if (i_io_close(ig))
+ return 0;
+
return 1;
}
store_32(lengths + offset_pos, comp_size);
offset_pos += 4;
current_offset += comp_size;
- if (ig->writecb(ig, comp_buf, comp_size) != comp_size) {
+ if (i_io_write(ig, comp_buf, comp_size) != comp_size) {
i_push_error(errno, "SGI image: error writing RLE data");
goto Error;
}
myfree(comp_buf);
myfree(linebuf);
+ if (i_io_close(ig))
+ return 0;
+
return 1;
Error:
unsigned short samp16 = SampleFTo16(linebuf[x]);
store_16(outp, samp16);
}
- if (ig->writecb(ig, encbuf, width * 2) != width * 2) {
+ if (i_io_write(ig, encbuf, width * 2) != width * 2) {
i_push_error(errno, "SGI image: error writing image data");
myfree(linebuf);
myfree(encbuf);
myfree(linebuf);
myfree(encbuf);
+ if (i_io_close(ig))
+ return 0;
+
return 1;
}
store_32(lengths + offset_pos, comp_size);
offset_pos += 4;
current_offset += comp_size;
- if (ig->writecb(ig, comp_buf, comp_size) != comp_size) {
+ if (i_io_write(ig, comp_buf, comp_size) != comp_size) {
i_push_error(errno, "SGI image: error writing RLE data");
goto Error;
}
myfree(linebuf);
myfree(sampbuf);
+ if (i_io_close(ig))
+ return 0;
+
return 1;
Error: