X backend properly converts image data
This commit is contained in:
parent
727a801243
commit
e21b57a915
26
x/window.go
26
x/window.go
@ -184,8 +184,12 @@ func (this *window) SetIcon (sizes ...canvas.Texture) {
|
|||||||
|
|
||||||
for _, icon := range sizes {
|
for _, icon := range sizes {
|
||||||
// TODO we use textures now. make this better
|
// TODO we use textures now. make this better
|
||||||
width := icon.Bounds().Max.X
|
icon, ok := icon.(*xcanvas.Texture)
|
||||||
height := icon.Bounds().Max.Y
|
if !ok { continue }
|
||||||
|
|
||||||
|
bounds := icon.Bounds()
|
||||||
|
width := bounds.Dx()
|
||||||
|
height := bounds.Dy()
|
||||||
wmIcon := ewmh.WmIcon {
|
wmIcon := ewmh.WmIcon {
|
||||||
Width: uint(width),
|
Width: uint(width),
|
||||||
Height: uint(height),
|
Height: uint(height),
|
||||||
@ -195,18 +199,14 @@ func (this *window) SetIcon (sizes ...canvas.Texture) {
|
|||||||
// manually convert image data beacuse of course we have to do
|
// manually convert image data beacuse of course we have to do
|
||||||
// this
|
// this
|
||||||
index := 0
|
index := 0
|
||||||
for y := 0; y < height; y ++ {
|
for y := bounds.Min.Y; y < bounds.Max.Y; y ++ {
|
||||||
for x := 0; x < width; x ++ {
|
for x := bounds.Min.X; x < bounds.Max.X; x ++ {
|
||||||
r, g, b, a := icon.At(x, y).RGBA()
|
pixel := icon.BGRAAt(x, y)
|
||||||
r >>= 8
|
|
||||||
g >>= 8
|
|
||||||
b >>= 8
|
|
||||||
a >>= 8
|
|
||||||
wmIcon.Data[index] =
|
wmIcon.Data[index] =
|
||||||
(uint(a) << 24) |
|
(uint(pixel.A) << 24) |
|
||||||
(uint(r) << 16) |
|
(uint(pixel.R) << 16) |
|
||||||
(uint(g) << 8) |
|
(uint(pixel.G) << 8) |
|
||||||
(uint(b) << 0)
|
(uint(pixel.B) << 0)
|
||||||
index ++
|
index ++
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user