noot
This commit is contained in:
parent
eebde0a484
commit
c04079691b
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
43
palette.go
43
palette.go
|
@ -5,15 +5,16 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"image/color"
|
"image/color"
|
||||||
"io"
|
"io"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type PaletteSection struct {
|
type PaletteSection struct {
|
||||||
Version uint32
|
Version uint32
|
||||||
Params [4]uint32
|
Params [4]uint32
|
||||||
Divided bool
|
OpaqueIndexCount uint32
|
||||||
DataLength uint32
|
DataLength uint32
|
||||||
Palette [256]color.Color
|
Palette [256]*color.RGBA
|
||||||
MainBound [2]uint32
|
MainBounds [2]uint32
|
||||||
|
|
||||||
lastSignature [4]byte
|
lastSignature [4]byte
|
||||||
}
|
}
|
||||||
|
@ -25,18 +26,16 @@ func (p *PaletteSection) Decode(rd io.Reader) error {
|
||||||
if sig, target := string(p.lastSignature[:]), "PAL_"; sig != target {
|
if sig, target := string(p.lastSignature[:]), "PAL_"; sig != target {
|
||||||
return fmt.Errorf("bad sig: want %s, got %s", target, sig)
|
return fmt.Errorf("bad sig: want %s, got %s", target, sig)
|
||||||
}
|
}
|
||||||
p.Palette = [256]color.Color{}
|
p.Palette = [256]*color.RGBA{}
|
||||||
if err := binary.Read(rd, end, &p.Version); err != nil {
|
if err := binary.Read(rd, end, &p.Version); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if err := binary.Read(rd, end, p.Params[:]); err != nil {
|
if err := binary.Read(rd, end, p.Params[:]); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
var cast uint32
|
if err := binary.Read(rd, end, &p.OpaqueIndexCount); err != nil {
|
||||||
if err := binary.Read(rd, end, &cast); err != nil {
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
p.Divided = (cast > 0)
|
|
||||||
if err := binary.Read(rd, end, &p.DataLength); err != nil {
|
if err := binary.Read(rd, end, &p.DataLength); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -58,10 +57,30 @@ func (p *PaletteSection) Decode(rd io.Reader) error {
|
||||||
alpha,
|
alpha,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if p.Divided {
|
|
||||||
if err := binary.Read(rd, end, p.MainBound[:]); err != nil {
|
for i := uint32(0); i < p.OpaqueIndexCount; i++ {
|
||||||
|
var first uint32
|
||||||
|
if err := binary.Read(rd, end, &first); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var last uint32
|
||||||
|
if err := binary.Read(rd, end, &last); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
log.Println("oic", p.OpaqueIndexCount, i, first, last)
|
||||||
|
// TODO: figure out what setBoard actually does
|
||||||
|
//p.setBoard(first, last, 255)
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *PaletteSection) setBoard(start uint32, end uint32, alpha int32) {
|
||||||
|
if !(start >= 0 && end >= 0 && start < 256 && end < 256) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
for i := start; i <= end; i++ {
|
||||||
|
p.Palette[i].A = uint8(alpha)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue