clip negatives off LABS L in tiff save

Negative L in LABS needs to be trimmed off before savingf as TIFF.
Thanks angelmixu.

See https://github.com/libvips/libvips/issues/1499
This commit is contained in:
John Cupitt 2019-12-13 12:45:49 +00:00
parent e236f19f97
commit 6fea2e7c57
1 changed files with 6 additions and 4 deletions

View File

@ -1235,23 +1235,25 @@ invert_band0( Wtiff *wtiff, VipsPel *q, VipsPel *p, int n )
static void
LabS2Lab16( VipsPel *q, VipsPel *p, int n, int samples_per_pixel )
{
int x;
short *p1 = (short *) p;
unsigned short *q1 = (unsigned short *) q;
int x;
for( x = 0; x < n; x++ ) {
int v;
int i;
/* TIFF uses unsigned 16 bit ... move zero, scale up L.
/* LABS L can be negative.
*/
q1[0] = VIPS_LSHIFT_INT( (int) p1[0], 1 );
q1[0] = VIPS_LSHIFT_INT( VIPS_MAX( 0, p1[0] ), 1 );
for( i = 1; i < samples_per_pixel; i++ )
q1[i] = p1[i];
q1 += samples_per_pixel;
p1 += samples_per_pixel;
}
}
}
/* Pack the pixels in @area from @in into a TIFF tile buffer.