support 1/2/4 bit palette tiff images with alpha
This commit is contained in:
parent
5ec80bf163
commit
b1b3c6e9de
@ -25,6 +25,7 @@
|
|||||||
- added vips_tiffload_buffer()
|
- added vips_tiffload_buffer()
|
||||||
- added vips_foreign_load_buffer(), vips_foreign_save_buffer()
|
- added vips_foreign_load_buffer(), vips_foreign_save_buffer()
|
||||||
- added vips_object_set_from_string()
|
- added vips_object_set_from_string()
|
||||||
|
- support 1/2/4 bit palette tiff images with alpha
|
||||||
|
|
||||||
6/3/14 started 7.38.6
|
6/3/14 started 7.38.6
|
||||||
- grey ramp minimum was wrong
|
- grey ramp minimum was wrong
|
||||||
|
@ -146,6 +146,8 @@
|
|||||||
* - palette images can have an alpha
|
* - palette images can have an alpha
|
||||||
* 22/4/14
|
* 22/4/14
|
||||||
* - add read from buffer
|
* - add read from buffer
|
||||||
|
* 30/4/14
|
||||||
|
* - 1/2/4 bit palette images can have alpha
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -707,12 +709,13 @@ typedef struct {
|
|||||||
gboolean mono;
|
gboolean mono;
|
||||||
} PaletteRead;
|
} PaletteRead;
|
||||||
|
|
||||||
/* Per-scanline process function for palette images.
|
/* 1/2/4 bit samples with an 8-bit palette.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
palette_line_bit( ReadTiff *rtiff, VipsPel *q, VipsPel *p, int n, void *client )
|
palette_line_bit( ReadTiff *rtiff, VipsPel *q, VipsPel *p, int n, void *client )
|
||||||
{
|
{
|
||||||
PaletteRead *read = (PaletteRead *) client;
|
PaletteRead *read = (PaletteRead *) client;
|
||||||
|
int samples = rtiff->samples_per_pixel;
|
||||||
|
|
||||||
int bit;
|
int bit;
|
||||||
VipsPel data;
|
VipsPel data;
|
||||||
@ -720,7 +723,7 @@ palette_line_bit( ReadTiff *rtiff, VipsPel *q, VipsPel *p, int n, void *client )
|
|||||||
|
|
||||||
bit = 0;
|
bit = 0;
|
||||||
data = 0;
|
data = 0;
|
||||||
for( x = 0; x < n; x++ ) {
|
for( x = 0; x < n * samples; x++ ) {
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if( bit <= 0 ) {
|
if( bit <= 0 ) {
|
||||||
@ -732,20 +735,25 @@ palette_line_bit( ReadTiff *rtiff, VipsPel *q, VipsPel *p, int n, void *client )
|
|||||||
data <<= rtiff->bits_per_sample;
|
data <<= rtiff->bits_per_sample;
|
||||||
bit -= rtiff->bits_per_sample;
|
bit -= rtiff->bits_per_sample;
|
||||||
|
|
||||||
if( read->mono ) {
|
/* The first band goes through the LUT, subsequent bands are
|
||||||
q[0] = read->red8[i];
|
* left-justified and copied.
|
||||||
q += 1;
|
*/
|
||||||
}
|
if( x % samples == 0 ) {
|
||||||
else {
|
if( read->mono )
|
||||||
q[0] = read->red8[i];
|
*q++ = read->red8[i];
|
||||||
q[1] = read->green8[i];
|
else {
|
||||||
q[2] = read->blue8[i];
|
q[0] = read->red8[i];
|
||||||
q += 3;
|
q[1] = read->green8[i];
|
||||||
|
q[2] = read->blue8[i];
|
||||||
|
q += 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
*q++ = i << (8 - rtiff->bits_per_sample);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The tiff is 8-bit and can have an alpha.
|
/* 8-bit samples with an 8-bit palette.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
palette_line8( ReadTiff *rtiff, VipsPel *q, VipsPel *p, int n,
|
palette_line8( ReadTiff *rtiff, VipsPel *q, VipsPel *p, int n,
|
||||||
@ -777,7 +785,7 @@ palette_line8( ReadTiff *rtiff, VipsPel *q, VipsPel *p, int n,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 16-bit tiff and can have an alpha.
|
/* 16-bit samples with 16-bit data in the palette.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
palette_line16( ReadTiff *rtiff, VipsPel *q, VipsPel *p, int n,
|
palette_line16( ReadTiff *rtiff, VipsPel *q, VipsPel *p, int n,
|
||||||
@ -827,13 +835,6 @@ parse_palette( ReadTiff *rtiff, VipsImage *out )
|
|||||||
return( -1 );
|
return( -1 );
|
||||||
len = 1 << rtiff->bits_per_sample;
|
len = 1 << rtiff->bits_per_sample;
|
||||||
|
|
||||||
if( rtiff->bits_per_sample < 8 &&
|
|
||||||
rtiff->samples_per_pixel > 1 ) {
|
|
||||||
vips_error( "tiff2vips", "%s", _( "can't have an alpha for "
|
|
||||||
"palette images less than 8 bits per sample" ) );
|
|
||||||
return( -1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !(read = VIPS_NEW( out, PaletteRead )) ||
|
if( !(read = VIPS_NEW( out, PaletteRead )) ||
|
||||||
!(read->red8 = VIPS_ARRAY( out, len, VipsPel )) ||
|
!(read->red8 = VIPS_ARRAY( out, len, VipsPel )) ||
|
||||||
!(read->green8 = VIPS_ARRAY( out, len, VipsPel )) ||
|
!(read->green8 = VIPS_ARRAY( out, len, VipsPel )) ||
|
||||||
|
Loading…
Reference in New Issue
Block a user