mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-09 15:38:13 -07:00
Merge pull request #104 from nvartolomei/png-16bit-alpha-background
fixes #103 flattening with background for 16bit transparent pngs
This commit is contained in:
commit
9c9b1c3e82
1 changed files with 10 additions and 0 deletions
10
vips.h
10
vips.h
|
|
@ -244,11 +244,21 @@ vips_webpsave_bridge(VipsImage *in, void **buf, size_t *len, int strip, int qual
|
|||
);
|
||||
}
|
||||
|
||||
int
|
||||
vips_is_16bit (VipsInterpretation interpretation) {
|
||||
return interpretation == VIPS_INTERPRETATION_RGB16 || interpretation == VIPS_INTERPRETATION_GREY16;
|
||||
}
|
||||
|
||||
int
|
||||
vips_flatten_background_brigde(VipsImage *in, VipsImage **out, double background[3]) {
|
||||
background[0] *= 256;
|
||||
background[1] *= 256;
|
||||
background[2] *= 256;
|
||||
|
||||
VipsArrayDouble *vipsBackground = vips_array_double_new(background, 3);
|
||||
return vips_flatten(in, out,
|
||||
"background", vipsBackground,
|
||||
"max_alpha", vips_is_16bit(in->Type) ? 65535.0 : 255.0,
|
||||
NULL
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue