Zig 0.17.0-dev (Split by item)

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.

BitmapHeader

Contains only the fields of BITMAPINFOHEADER (WinGDI.h) that are both:

ico.BitmapHeader
pub const BitmapHeader = extern struct

File

Code

pub const BitmapHeader = extern struct {
    bcSize: u32,
    bcWidth: i32,
    bcHeight: i32,
    bcPlanes: u16,
    bcBitCount: u16,

    pub fn version(self: *const BitmapHeader) Version {
        return Version.get(self.bcSize);
    }

    /// https://en.wikipedia.org/wiki/BMP_file_format#DIB_header_(bitmap_information_header)
    pub const Version = enum(u3) {
        unknown,
        @"win2.0", // Windows 2.0 or later
        @"nt3.1", // Windows NT, 3.1x or later
        @"nt4.0", // Windows NT 4.0, 95 or later
        @"nt5.0", // Windows NT 5.0, 98 or later

        pub fn get(header_size: u32) Version {
            return switch (header_size) {
                len(.@"win2.0") => .@"win2.0",
                len(.@"nt3.1") => .@"nt3.1",
                len(.@"nt4.0") => .@"nt4.0",
                len(.@"nt5.0") => .@"nt5.0",
                else => .unknown,
            };
        }

        pub fn len(comptime v: Version) comptime_int {
            return switch (v) {
                .@"win2.0" => 12,
                .@"nt3.1" => 40,
                .@"nt4.0" => 108,
                .@"nt5.0" => 124,
                .unknown => unreachable,
            };
        }

        pub fn nameForErrorDisplay(v: Version) []const u8 {
            return switch (v) {
                .unknown => "unknown",
                .@"win2.0" => "Windows 2.0 (BITMAPCOREHEADER)",
                .@"nt3.1" => "Windows NT, 3.1x (BITMAPINFOHEADER)",
                .@"nt4.0" => "Windows NT 4.0, 95 (BITMAPV4HEADER)",
                .@"nt5.0" => "Windows NT 5.0, 98 (BITMAPV5HEADER)",
            };
        }
    };
}