fixed transparency issue

This commit is contained in:
elee 2022-03-25 05:28:36 -05:00
parent 0f5e1f4c0a
commit 1bcae21244
3 changed files with 15 additions and 1 deletions

View File

@ -55,6 +55,9 @@ func (i *Image) Decode(rd *bufio.Reader, palette *PaletteSection) error {
if red == 0xff && blue == 0xff { if red == 0xff && blue == 0xff {
alpha = 0x00 alpha = 0x00
} }
if red == 0x00 && blue == 0x00 && green == 0xff {
alpha = 0x00
}
col := &color.RGBA{ col := &color.RGBA{
red, green, blue, red, green, blue,
alpha, alpha,
@ -75,6 +78,10 @@ func (i *Image) Decode(rd *bufio.Reader, palette *PaletteSection) error {
rgb[0], rgb[1], rgb[2], rgb[0], rgb[1], rgb[2],
alpha, alpha,
} }
if rgb[0] == 0x00 && rgb[1] == 0xff && rgb[2] == 0x00 {
alpha = 0x00
}
if rgb[0] == 0xff && rgb[2] == 0xff { if rgb[0] == 0xff && rgb[2] == 0xff {
alpha = 0x00 alpha = 0x00
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 577 KiB

After

Width:  |  Height:  |  Size: 580 KiB

View File

@ -157,9 +157,16 @@ func (n *Reader) decodePalette() error {
if err != nil { if err != nil {
return err return err
} }
alpha := uint8(0xff)
if rgb[0] == 0x00 && rgb[1] == 0xff && rgb[2] == 0x00 {
alpha = 0x00
}
if rgb[0] == 0xff && rgb[2] == 0xff {
alpha = 0x00
}
cp.Palette[i] = &color.RGBA{ cp.Palette[i] = &color.RGBA{
rgb[0], rgb[1], rgb[2], rgb[0], rgb[1], rgb[2],
0xff, alpha,
} }
} }