This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.
pubconstBitmapInfo = struct {
dib_header_size: u32,
/// Contains the interpreted number of colors in the palette (e.g./// if the field's value is zero and the bit depth is <= 8, this/// will contain the maximum number of colors for the bit depth/// rather than the field's value directly).colors_in_palette: u32,
bytes_per_color_palette_element: u8,
pixel_data_offset: u32,
compression: Compression,
pubfngetExpectedPaletteByteLen(self: *constBitmapInfo) u64 {
return@as(u64, self.colors_in_palette) * self.bytes_per_color_palette_element;
}
pubfngetActualPaletteByteLen(self: *constBitmapInfo) u64 {
returnself.getByteLenBetweenHeadersAndPixels() - self.getBitmasksByteLen();
}
pubfngetByteLenBetweenHeadersAndPixels(self: *constBitmapInfo) u64 {
return@as(u64, self.pixel_data_offset) - self.dib_header_size - file_header_len;
}
pubfngetBitmasksByteLen(self: *constBitmapInfo) u8 {
// Only BITMAPINFOHEADER (3.1) has trailing bytes for the BITFIELDS
// The 2.0 format doesn't have a compression field and 4.0+ has dedicated
// fields for the masks in the header.
constdib_version = BitmapHeader.Version.get(self.dib_header_size);
returnswitch (dib_version) {
.@"nt3.1" => switch (self.compression) {
.BI_BITFIELDS => 12,
.BI_ALPHABITFIELDS => 16,
else => 0,
},
else => 0,
};
}
pubfngetMissingPaletteByteLen(self: *constBitmapInfo) u64 {
if (self.getActualPaletteByteLen() >= self.getExpectedPaletteByteLen()) return0;
returnself.getExpectedPaletteByteLen() - self.getActualPaletteByteLen();
}
/// Returns the full byte len of the DIB header + optional bitmasks + color palettepubfngetExpectedByteLenBeforePixelData(self: *constBitmapInfo) u64 {
return@as(u64, self.dib_header_size) + self.getBitmasksByteLen() + self.getExpectedPaletteByteLen();
}
/// Returns the full expected byte lenpubfngetExpectedByteLen(self: *constBitmapInfo, file_size: u64) u64 {
returnself.getExpectedByteLenBeforePixelData() + self.getPixelDataLen(file_size);
}
pubfngetPixelDataLen(self: *constBitmapInfo, file_size: u64) u64 {
returnfile_size - self.pixel_data_offset;
}
}