1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-05 09:47:18 -05:00
OpenDiablo2/d2common/d2fileformats/d2dat/dat.go
dk c1a88c9cf7
Animation manager abstraction (#544)
* abstracted palettes, colors, and palette manager

* make asset manager use the palette manager interface

* added BGRA setter/getter, fixed lint errors

* abstraction for animation and animation manager
2020-07-05 13:01:44 -04:00

24 lines
425 B
Go

package d2dat
import "github.com/OpenDiablo2/OpenDiablo2/d2common/d2interface"
const (
// index offset helpers
b = iota
g
r
o
)
// Load loads a DAT file.
func Load(data []byte) (d2interface.Palette, error) {
palette := &DATPalette{}
for i := 0; i < 256; i++ {
// offsets look like i*3+n, where n is 0,1,2
palette.colors[i] = &DATColor{b: data[i*o+b], g: data[i*o+g], r: data[i*o+r]}
}
return palette, nil
}