-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathcanvas.go
55 lines (41 loc) · 1 KB
/
canvas.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
package wz
type WZCanvas struct {
*WZImageObject
Width int32
Height int32
Format int32
MagLevel uint8
data []byte
Properties WZProperty
}
func NewWZCanvas(name string, parent *WZSimpleNode) *WZCanvas {
node := new(WZCanvas)
node.WZImageObject = NewWZImageObject(name, parent)
return node
}
func (m *WZCanvas) Parse(file *WZFileBlob, offset int64) {
if file.Debug {
m.debug(file, "> WZCanvas::Parse")
defer func() { m.debug(file, "< WZCanvas::Parse") }()
}
file.skip(1)
if file.readByte() == 1 {
m.Properties = ParseProperty(m.WZSimpleNode, file, offset)
}
m.Width = file.readWZInt()
m.Height = file.readWZInt()
if m.Width >= 0x10000 || m.Height >= 0x10000 {
panic("File corrupt? Width and/or Height is too big.")
}
m.Format = file.readWZInt()
m.MagLevel = file.readByte()
if file.readInt32() != 0 {
panic("4 bytes must equal zero.")
}
len := file.readInt32()
m.debug(file, "Canvas len: ", len)
len -= 1
// skip first byte
file.skip(1)
m.data = file.readBytes(len)
}