1
0
mirror of https://github.com/imgproxy/imgproxy.git synced 2025-11-27 22:48:53 +02:00

Add C.RGB struct

This commit is contained in:
DarthSim
2025-05-13 19:03:38 +03:00
parent 2584f689c6
commit 9b59fb2d53
3 changed files with 31 additions and 19 deletions

View File

@@ -301,6 +301,14 @@ func gbool(b bool) C.gboolean {
return C.gboolean(0)
}
func cRGB(c Color) C.RGB {
return C.RGB{
r: C.double(c.R),
g: C.double(c.G),
b: C.double(c.B),
}
}
func ptrToBytes(ptr unsafe.Pointer, size int) []byte {
return (*[math.MaxInt32]byte)(ptr)[:int(size):int(size)]
}
@@ -695,8 +703,7 @@ func (img *Image) Trim(threshold float64, smart bool, color Color, equalHor bool
}
if C.vips_trim(img.VipsImage, &tmp, C.double(threshold),
gbool(smart), C.double(color.R), C.double(color.G), C.double(color.B),
gbool(equalHor), gbool(equalVer)) != 0 {
gbool(smart), cRGB(color), gbool(equalHor), gbool(equalVer)) != 0 {
return Error()
}
@@ -707,7 +714,7 @@ func (img *Image) Trim(threshold float64, smart bool, color Color, equalHor bool
func (img *Image) Flatten(bg Color) error {
var tmp *C.VipsImage
if C.vips_flatten_go(img.VipsImage, &tmp, C.double(bg.R), C.double(bg.G), C.double(bg.B)) != 0 {
if C.vips_flatten_go(img.VipsImage, &tmp, cRGB(bg)) != 0 {
return Error()
}
C.swap_and_clear(&img.VipsImage, tmp)