Merge pull request #414 from imprity/NewImageFromImage-fix

Fix NewImageFromImage color converting
This commit is contained in:
Milan Nikolic 2024-09-16 07:06:33 +02:00 committed by GitHub
commit 6bc3d79c96
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 2 additions and 2 deletions

View file

@ -3776,7 +3776,7 @@ func NewImageFromImage(img image.Image) *Image {
for x := 0; x < size.X; x++ {
col := img.At(x, y)
r, g, b, a := col.RGBA()
rcolor := NewColor(uint8(r), uint8(g), uint8(b), uint8(a))
rcolor := NewColor(uint8(r>>8), uint8(g>>8), uint8(b>>8), uint8(a>>8))
ImageDrawPixel(ret, int32(x), int32(y), rcolor)
}
}

View file

@ -69,7 +69,7 @@ func NewImageFromImage(img image.Image) *Image {
for x := 0; x < size.X; x++ {
color := img.At(x, y)
r, g, b, a := color.RGBA()
rcolor := NewColor(uint8(r), uint8(g), uint8(b), uint8(a))
rcolor := NewColor(uint8(r>>8), uint8(g>>8), uint8(b>>8), uint8(a>>8))
ccolor = colorCptr(rcolor)
cx = (C.int)(x)