forked from old/legacy-imlib2
parent
c7388db2ae
commit
2c4149fee4
|
@ -132,18 +132,19 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
{
|
{
|
||||||
TIFF *tif = NULL;
|
TIFF *tif = NULL;
|
||||||
FILE *file;
|
FILE *file;
|
||||||
int fd;
|
int fd, ok;
|
||||||
uint16 magic_number;
|
uint16 magic_number;
|
||||||
TIFFRGBAImage_Extra rgba_image;
|
TIFFRGBAImage_Extra rgba_image;
|
||||||
uint32 *rast = NULL;
|
uint32 *rast = NULL;
|
||||||
uint32 width, height, num_pixels;
|
uint32 width, height, num_pixels;
|
||||||
char txt[1024];
|
char txt[1024];
|
||||||
|
|
||||||
|
ok = 0;
|
||||||
|
|
||||||
if (im->data)
|
if (im->data)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
file = fopen(im->real_file, "rb");
|
file = fopen(im->real_file, "rb");
|
||||||
|
|
||||||
if (!file)
|
if (!file)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
@ -164,32 +165,21 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
fclose(file);
|
fclose(file);
|
||||||
|
|
||||||
tif = TIFFFdOpen(fd, im->real_file, "r");
|
tif = TIFFFdOpen(fd, im->real_file, "r");
|
||||||
|
|
||||||
if (!tif)
|
if (!tif)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
strcpy(txt, "Cannot be processed by libtiff");
|
strcpy(txt, "Cannot be processed by libtiff");
|
||||||
if (!TIFFRGBAImageOK(tif, txt))
|
if (!TIFFRGBAImageOK(tif, txt))
|
||||||
{
|
goto quit1;
|
||||||
TIFFClose(tif);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
strcpy(txt, "Cannot begin reading tiff");
|
strcpy(txt, "Cannot begin reading tiff");
|
||||||
if (!TIFFRGBAImageBegin((TIFFRGBAImage *) & rgba_image, tif, 1, txt))
|
if (!TIFFRGBAImageBegin((TIFFRGBAImage *) & rgba_image, tif, 1, txt))
|
||||||
{
|
goto quit1;
|
||||||
TIFFClose(tif);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
rgba_image.image = im;
|
rgba_image.image = im;
|
||||||
im->w = width = rgba_image.rgba.width;
|
im->w = width = rgba_image.rgba.width;
|
||||||
im->h = height = rgba_image.rgba.height;
|
im->h = height = rgba_image.rgba.height;
|
||||||
if (!IMAGE_DIMENSIONS_OK(width, height))
|
if (!IMAGE_DIMENSIONS_OK(width, height))
|
||||||
{
|
goto quit2;
|
||||||
TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
|
|
||||||
TIFFClose(tif);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
rgba_image.num_pixels = num_pixels = width * height;
|
rgba_image.num_pixels = num_pixels = width * height;
|
||||||
if (rgba_image.rgba.alpha != EXTRASAMPLE_UNSPECIFIED)
|
if (rgba_image.rgba.alpha != EXTRASAMPLE_UNSPECIFIED)
|
||||||
SET_FLAG(im->flags, F_HAS_ALPHA);
|
SET_FLAG(im->flags, F_HAS_ALPHA);
|
||||||
|
@ -217,11 +207,7 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
free(im->data);
|
free(im->data);
|
||||||
im->data = NULL;
|
im->data = NULL;
|
||||||
}
|
}
|
||||||
|
goto quit2;
|
||||||
TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
|
|
||||||
TIFFClose(tif);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rgba_image.rgba.put.any == NULL)
|
if (rgba_image.rgba.put.any == NULL)
|
||||||
|
@ -231,23 +217,18 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
_TIFFfree(rast);
|
_TIFFfree(rast);
|
||||||
free(im->data);
|
free(im->data);
|
||||||
im->data = NULL;
|
im->data = NULL;
|
||||||
TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
|
goto quit2;
|
||||||
TIFFClose(tif);
|
}
|
||||||
|
|
||||||
return 0;
|
if (rgba_image.rgba.isContig)
|
||||||
|
{
|
||||||
|
rgba_image.put_contig = rgba_image.rgba.put.contig;
|
||||||
|
rgba_image.rgba.put.contig = put_contig_and_raster;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (rgba_image.rgba.isContig)
|
rgba_image.put_separate = rgba_image.rgba.put.separate;
|
||||||
{
|
rgba_image.rgba.put.separate = put_separate_and_raster;
|
||||||
rgba_image.put_contig = rgba_image.rgba.put.contig;
|
|
||||||
rgba_image.rgba.put.contig = put_contig_and_raster;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rgba_image.put_separate = rgba_image.rgba.put.separate;
|
|
||||||
rgba_image.rgba.put.separate = put_separate_and_raster;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!TIFFRGBAImageGet((TIFFRGBAImage *) & rgba_image,
|
if (!TIFFRGBAImageGet((TIFFRGBAImage *) & rgba_image,
|
||||||
|
@ -256,19 +237,19 @@ load(ImlibImage * im, ImlibProgressFunction progress,
|
||||||
_TIFFfree(rast);
|
_TIFFfree(rast);
|
||||||
free(im->data);
|
free(im->data);
|
||||||
im->data = NULL;
|
im->data = NULL;
|
||||||
TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
|
goto quit2;
|
||||||
TIFFClose(tif);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_TIFFfree(rast);
|
_TIFFfree(rast);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ok = 1;
|
||||||
|
quit2:
|
||||||
TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
|
TIFFRGBAImageEnd((TIFFRGBAImage *) & rgba_image);
|
||||||
|
quit1:
|
||||||
TIFFClose(tif);
|
TIFFClose(tif);
|
||||||
|
|
||||||
return 1;
|
return ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this seems to work, except the magic number isn't written. I'm guessing */
|
/* this seems to work, except the magic number isn't written. I'm guessing */
|
||||||
|
|
Loading…
Reference in New Issue