image.decoders.common
fn new_bitreader_lsb #
fn new_bitreader_lsb(data []u8) BitReader
new_bitreader_lsb creates an LSB-first reader.
fn new_bitreader_msb #
fn new_bitreader_msb(data []u8) BitReader
new_bitreader_msb creates an MSB-first reader.
struct Animation #
struct Animation {
pub:
frames []Frame
loop_count int // 0 = forever, >= 1 finite
}
Animation is a sequence of frames with a loop count.
struct BitReader #
struct BitReader {
mut:
data []u8
byte_pos int
bit_pos int // bits already consumed in the current byte (0..8)
msb bool
}
BitReader reads bits from a byte buffer in either LSB-first (GIF/WebP) or MSB-first (JPEG) order. Format-specific byte stuffing (e.g. JPEG FF00) is handled by the caller.
fn (BitReader) read_bits #
fn (mut r BitReader) read_bits(n int) !u32
read_bits reads up to 32 bits and returns them as a u32. Bits are assembled in the order they are read.
fn (BitReader) align_bytes #
fn (mut r BitReader) align_bytes()
align_bytes skips to the next byte boundary (no-op if already aligned).
fn (BitReader) remaining #
fn (r BitReader) remaining() int
remaining returns the number of whole bytes left (approximate).
struct Frame #
struct Frame {
pub:
image Image
delay_ms int
disposal int
}
Frame is one coalesced animation frame.
struct Image #
struct Image {
pub:
width int
height int
rgba []u8 // len == width * height * 4
}
Image is a decoded, top-down RGBA image (straight, non-premultiplied alpha).