package core:image/netpbm

⌘K
Ctrl+K
or
/

    Overview

    Formats:

    PBM (P1, P4): Portable Bit Map,       stores black and white images   (1 channel)
    PGM (P2, P5): Portable Gray Map,      stores greyscale images         (1 channel, 1 or 2 bytes per value)
    PPM (P3, P6): Portable Pixel Map,     stores colour images            (3 channel, 1 or 2 bytes per value)
    PAM (P7    ): Portable Arbitrary Map, stores arbitrary channel images            (1 or 2 bytes per value)
    PFM (Pf, PF): Portable Float Map,     stores floating-point images    (Pf: 1 channel, PF: 3 channel)
    
    

    Reading:

    All formats fill out header fields format, width, height, channels, depth. Specific formats use more fields:

    PGM, PPM, and PAM set `maxval` (maximum of 65535)
    PAM sets `tupltype` if there is one, and can set `channels` to any value (not just 1 or 3)
    PFM sets `scale` (float equivalent of `maxval`) and `little_endian` (endianness of stored floats)
    

    Currently doesn't support reading multiple images from one binary-format file.

    Writing:

    You can use your own Netpbm_Info struct to control how images are written. All formats require the header field format to be specified. Additional header fields are required for specific formats:

    PGM, PPM, and PAM require `maxval` (maximum of 65535)
    PAM also uses `tupltype`, though it may be left as default (empty or nil string)
    PFM requires `scale`, and optionally `little_endian`
    
    

    Some syntax differences from the specifications:

    channels stores the number of values per pixel, what the PAM specification calls depth depth instead is the number of bits for a single value (32 for PFM, 16 or 8 otherwise) scale and little_endian are separated, so the header will always store a positive scale little_endian will only be true for a negative scale PFM, every other format will be false little_endian only describes the netpbm data being read/written, the image buffer will be native

    Types

    Error ¶

    Error :: image.Error

    Format_Error ¶

    Format_Error :: image.Netpbm_Error

    Formats ¶

    Formats :: bit_set[image.Netpbm_Format]
    Related Constants

    Image ¶

    Image :: image.Image

    Info ¶

    Info :: image.Netpbm_Info

    Constants

    ASCII ¶

    ASCII: bit_set[image.Netpbm_Format] : Formats{.P1, .P2, .P3}

    BINARY ¶

    BINARY: bit_set[image.Netpbm_Format] : Formats{.P4, .P5, .P6} + PAM + PFM

    PAM ¶

    PAM: bit_set[image.Netpbm_Format] : Formats{.P7}

    PBM ¶

    PBM: bit_set[image.Netpbm_Format] : Formats{.P1, .P4}

    PFM ¶

    PFM: bit_set[image.Netpbm_Format] : Formats{.Pf, .PF}

    PGM ¶

    PGM: bit_set[image.Netpbm_Format] : Formats{.P2, .P5}

    PNM ¶

    PNM: bit_set[image.Netpbm_Format] : PBM + PGM + PPM

    PPM ¶

    PPM: bit_set[image.Netpbm_Format] : Formats{.P3, .P6}

    Variables

    This section is empty.

    Procedures

    autoselect_pbm_format_from_image ¶

    autoselect_pbm_format_from_image :: proc(img: ^image.Image, prefer_binary: bool = true, force_black_and_white: bool = false, pfm_scale: f32 = f32(1.0)) -> (res: image.Netpbm_Info, ok: bool) {…}
     

    Automatically try to select an appropriate format to save to based on img.channel and img.depth

    decode_image ¶

    decode_image :: proc(img: ^image.Image, header: image.Netpbm_Header, data: []u8, allocator := context.allocator) -> (err: image.Error) {…}

    destroy ¶

    destroy :: proc(img: ^image.Image) -> bool {…}

    header_destroy ¶

    header_destroy :: proc(header: ^image.Netpbm_Header) {…}

    load_from_bytes ¶

    load_from_bytes :: proc(data: []u8, allocator := context.allocator) -> (img: ^image.Image, err: image.Error) {…}

    load_from_file ¶

    load_from_file :: proc(filename: string, allocator := context.allocator) -> (img: ^image.Image, err: image.Error) {…}

    parse_header ¶

    parse_header :: proc(data: []u8, allocator := context.allocator) -> (header: image.Netpbm_Header, length: int, err: image.Error) {…}

    save_to_buffer ¶

    save_to_buffer :: proc(img: ^image.Image, custom_info: image.Netpbm_Info = {}, allocator := context.allocator) -> (buffer: []u8, err: image.Error) {…}

    save_to_file ¶

    save_to_file :: proc(filename: string, img: ^image.Image, custom_info: image.Netpbm_Info = {}, allocator := context.allocator) -> (err: image.Error) {…}

    Procedure Groups

    Source Files

    Generation Information

    Generated with odin version dev-2024-04 (vendor "odin") Windows_amd64 @ 2024-04-19 21:09:18.678008200 +0000 UTC