mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-20 16:47:28 +01:00
29 lines
686 B
Plaintext
29 lines
686 B
Plaintext
// Use of this source code is governed by a BSD-style license that can be found
|
|
// in the LICENSE file.
|
|
|
|
// The GIF spec is https://www.w3.org/Graphics/GIF/spec-gif89a.txt
|
|
|
|
pub error "bad GIF header"
|
|
|
|
pub struct decoder?(
|
|
lzw lzw_decoder,
|
|
)
|
|
|
|
pub func decoder.decode?(dst ptr buf1, src ptr buf1)() {
|
|
this.decode_header?(src:in.src)
|
|
}
|
|
|
|
// decode_header reads either "GIF87a" or "GIF89a".
|
|
pri func decoder.decode_header?(src ptr buf1)() {
|
|
var c[6] u8
|
|
var i u8
|
|
while i < 6 {
|
|
c[i] = in.src.read_u8?()
|
|
i += 1
|
|
}
|
|
if (c[0] != 0x47) or (c[1] != 0x49) or (c[2] != 0x46) or (c[3] != 0x38) or
|
|
((c[4] != 0x37) and (c[4] != 0x39)) or (c[5] != 0x61) {
|
|
return error "bad GIF header"
|
|
}
|
|
}
|