scale openexr alpha up

scale alpha up to 0 - 255 to match the rest of libvips
This commit is contained in:
John Cupitt 2018-08-19 10:53:54 +01:00
parent b92c55770f
commit f4250ab7ab
2 changed files with 20 additions and 0 deletions

View File

@ -38,6 +38,8 @@
- magickload now sniffs some file types itself
- update radiance load from upstream
- mapim could fail for float index images with coordinates out of int range
- scale openexr alpha to 0 - 255
- close input earlier, when we can [kleisauke]
12/3/18 started 8.6.4
- better fitting of fonts with overhanging edges [Adrià]

View File

@ -16,6 +16,8 @@
* - tag output as scRGB
* 16/8/18
* - shut down the input file as soon as we can [kleisauke]
* 19/8/18
* - scale alpha up to 0 - 255 to match the rest of libvips
*/
/*
@ -332,8 +334,16 @@ vips__openexr_generate( VipsRegion *out,
float *q = (float *) VIPS_REGION_ADDR( out,
hit.left, hit.top + z );
int i;
ImfHalfToFloatArray( 4 * hit.width,
(ImfHalf *) p, q );
/* oexr uses 0 - 1 for alpha, but vips is
* always 0 - 255, even for scrgb images.
*/
for( i = 0; i < hit.width; i++ )
q[4 * i + 3] *= 255;
}
}
@ -402,6 +412,8 @@ vips__openexr_read( const char *filename, VipsImage *out )
read_header( read, out );
for( y = 0; y < height; y++ ) {
int i;
if( !ImfInputSetFrameBuffer( read->lines,
imf_buffer - left - (top + y) * width,
1, width ) ) {
@ -417,6 +429,12 @@ vips__openexr_read( const char *filename, VipsImage *out )
ImfHalfToFloatArray( 4 * width,
(ImfHalf *) imf_buffer, vips_buffer );
/* oexr uses 0 - 1 for alpha, but vips is always 0 -
* 255, even for scrgb images.
*/
for( i = 0; i < width; i++ )
vips_buffer[4 * i + 3] *= 255;
if( vips_image_write_line( out, y,
(VipsPel *) vips_buffer ) )
return( -1 );