TIFF loader: Properly suppress messages from libtiff

This commit is contained in:
Kim Woelders 2024-01-03 20:02:07 +01:00
parent c0d2bce375
commit 66f39b6556
1 changed files with 16 additions and 0 deletions

View File

@ -10,6 +10,16 @@ static const char *const _formats[] = { "tiff", "tif" };
#define DD(fmt...) DC(DBG_PFX, 0x80, fmt)
static void
_tiff_error(const char *module, const char *fmt, va_list ap)
{
#if IMLIB2_DEBUG
char buf[128];
vsnprintf(buf, sizeof(buf), fmt, ap);
D("%s: %s: %s\n", __func__, module, buf);
#endif
}
static struct {
const unsigned char *data, *dptr;
unsigned int size;
@ -364,6 +374,9 @@ _load(ImlibImage *im, int load_data)
mm_init(im->fi->fdata, im->fi->fsize);
TIFFSetErrorHandler(_tiff_error);
TIFFSetWarningHandler(_tiff_error);
tif = TIFFClientOpen(im->fi->name, "r", NULL, _tiff_read, _tiff_write,
_tiff_seek, _tiff_close, _tiff_size,
_tiff_map, _tiff_unmap);
@ -470,6 +483,9 @@ _save(ImlibImage *im)
int i;
ImlibImageTag *tag;
TIFFSetErrorHandler(_tiff_error);
TIFFSetWarningHandler(_tiff_error);
tif = TIFFFdOpen(fileno(im->fi->fp), im->fi->name, "w");
if (!tif)
return LOAD_FAIL;