SDL surface is created from non-alpha-premultiplied colors.
This commit is contained in:
parent
0fe9a2ce63
commit
39766e9f01
@ -5,6 +5,16 @@ import (
|
||||
"image/draw"
|
||||
)
|
||||
|
||||
func NRGBAImage(m image.Image) *image.NRGBA {
|
||||
nrgba, ok := m.(*image.NRGBA)
|
||||
if ok {
|
||||
return nrgba
|
||||
}
|
||||
nrgba = image.NewNRGBA(m.Bounds())
|
||||
draw.Draw(nrgba, nrgba.Bounds(), m, image.ZP, draw.Over)
|
||||
return nrgba
|
||||
}
|
||||
|
||||
func RGBAImage(m image.Image) *image.RGBA {
|
||||
rgba, ok := m.(*image.RGBA)
|
||||
if ok {
|
||||
|
@ -243,7 +243,7 @@ func (r *Renderer) createTexture(source ui.ImageSource, keepSource bool) (ui.Tex
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
rgba := RGBAImage(m)
|
||||
rgba := NRGBAImage(m)
|
||||
width := int32(rgba.Bounds().Dx())
|
||||
height := int32(rgba.Bounds().Dy())
|
||||
surface, err := sdl.CreateRGBSurfaceWithFormatFrom(
|
||||
@ -257,6 +257,7 @@ func (r *Renderer) createTexture(source ui.ImageSource, keepSource bool) (ui.Tex
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
texture.SetBlendMode(sdl.BLENDMODE_BLEND)
|
||||
if keepSource {
|
||||
return &TextureImageSource{&Texture{texture}, source}, nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user