Skip to content

Commit

Permalink
Don't read text colors as 4 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
Ziemas committed Aug 29, 2021
1 parent e456c73 commit a8c205d
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions pkg/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ func (pl2 *PL2) Decode(rs io.ReadSeeker) (*PL2, error) {
return pl2, nil
}

func (pl2 *PL2) decodeColors(stream *bitstream.Reader, dst color.Palette) error {
func (pl2 *PL2) decodeColors(stream *bitstream.Reader, dst color.Palette, colorBytes int) error {
const (
colorBytes = 4
rOff, gOff, bOff = 0, 1, 2 // rgb offsets in the returned bytes
)

Expand All @@ -55,13 +54,13 @@ func (pl2 *PL2) decodeColors(stream *bitstream.Reader, dst color.Palette) error
func (pl2 *PL2) decodeBasePalette(stream *bitstream.Reader) error {
pl2.BasePalette = make(color.Palette, numPaletteColors)

return pl2.decodeColors(stream, pl2.BasePalette)
return pl2.decodeColors(stream, pl2.BasePalette, 4)
}

func (pl2 *PL2) decodeTextColors(stream *bitstream.Reader) error {
pl2.TextColors = make(color.Palette, numTextColors)

return pl2.decodeColors(stream, pl2.TextColors)
return pl2.decodeColors(stream, pl2.TextColors, 3)
}

func (pl2 *PL2) decodeTransforms(stream *bitstream.Reader) (err error) {
Expand Down

0 comments on commit a8c205d

Please sign in to comment.