mirror of
https://github.com/talgo-cloud/bimg.git
synced 2026-03-11 00:10:27 -07:00
fix(background): pass proper background RGB color
This commit is contained in:
parent
bffc7652bb
commit
5ca57a1e68
3 changed files with 5 additions and 7 deletions
|
|
@ -330,7 +330,6 @@ func imageFlatten(image *C.VipsImage, imageType ImageType, o Options) (*C.VipsIm
|
|||
if imageType != PNG || o.Background == ColorBlack {
|
||||
return image, nil
|
||||
}
|
||||
|
||||
return vipsFlattenBackground(image, o.Background)
|
||||
}
|
||||
|
||||
|
|
|
|||
3
vips.go
3
vips.go
|
|
@ -304,7 +304,8 @@ func vipsFlattenBackground(image *C.VipsImage, background Color) (*C.VipsImage,
|
|||
}
|
||||
|
||||
if vipsHasAlpha(image) {
|
||||
err := C.vips_flatten_background_brigde(image, &outImage, (*C.double)(&backgroundC[0]))
|
||||
err := C.vips_flatten_background_brigde(image, &outImage,
|
||||
backgroundC[0], backgroundC[1], backgroundC[2])
|
||||
if int(err) != 0 {
|
||||
return nil, catchVipsError()
|
||||
}
|
||||
|
|
|
|||
8
vips.h
8
vips.h
|
|
@ -277,12 +277,10 @@ vips_is_16bit (VipsInterpretation interpretation) {
|
|||
}
|
||||
|
||||
int
|
||||
vips_flatten_background_brigde(VipsImage *in, VipsImage **out, double background[3]) {
|
||||
background[0] *= 256;
|
||||
background[1] *= 256;
|
||||
background[2] *= 256;
|
||||
|
||||
vips_flatten_background_brigde(VipsImage *in, VipsImage **out, double r, double g, double b) {
|
||||
double background[3] = {r, g, b};
|
||||
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue