mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 23:28:48 +00:00
Fixed the depth values in the doc file, made some info more clear
This commit is contained in:
@@ -6,24 +6,25 @@ Formats:
|
|||||||
PAM (P7 ): Portable Arbitrary Map, stores arbitrary channel images (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)
|
PFM (Pf, PF): Portable Float Map, stores floating-point images (Pf: 1 channel, PF: 3 channel)
|
||||||
|
|
||||||
Reading
|
Reading:
|
||||||
All formats fill out header fields `format`, `width`, `height`, `channels`, `depth`
|
All formats fill out header fields `format`, `width`, `height`, `channels`, `depth`
|
||||||
Specific formats use more fields
|
Specific formats use more fields
|
||||||
PGM, PPM, and PAM set `maxval`
|
PGM, PPM, and PAM set `maxval` (maximum of 65535)
|
||||||
PAM also sets `tupltype`, and is able to set `channels` to an arbitrary value
|
PAM sets `tupltype` if there is one, and can set `channels` to any value (not just 1 or 3)
|
||||||
PFM sets `scale` and `little_endian`
|
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
|
Currently doesn't support reading multiple images from one binary-format file
|
||||||
|
|
||||||
Writing
|
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
|
All formats require the header field `format` to be specified
|
||||||
Additional header fields are required for specific formats
|
Additional header fields are required for specific formats
|
||||||
PGM, PPM, and PAM require `maxval`
|
PGM, PPM, and PAM require `maxval` (maximum of 65535)
|
||||||
PAM also uses `tupltype`, though it may be left as default (empty or nil string)
|
PAM also uses `tupltype`, though it may be left as default (empty or nil string)
|
||||||
PFM requires `scale` and `little_endian`, though the latter may be left untouched (default is false)
|
PFM requires `scale`, and optionally `little_endian`
|
||||||
|
|
||||||
Some syntax differences from the specifications:
|
Some syntax differences from the specifications:
|
||||||
`channels` stores what the PAM specification calls `depth`
|
`channels` stores the number of values per pixel, what the PAM specification calls `depth`
|
||||||
`depth` instead stores how many bytes will fit `maxval` (should only be 1, 2, or 4)
|
`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`
|
`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` 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
|
`little_endian` only describes the netpbm data being read/written, the image buffer will be native
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ save_to_buffer :: proc(img: ^Image, custom_info: Info = {}, allocator := context
|
|||||||
// using info so we can just talk about the header
|
// using info so we can just talk about the header
|
||||||
using info
|
using info
|
||||||
|
|
||||||
//? validation
|
// validation
|
||||||
if header.format in (PBM + PGM + Formats{.Pf}) && img.channels != 1 \
|
if header.format in (PBM + PGM + Formats{.Pf}) && img.channels != 1 \
|
||||||
|| header.format in (PPM + Formats{.PF}) && img.channels != 3 {
|
|| header.format in (PPM + Formats{.PF}) && img.channels != 3 {
|
||||||
err = .Invalid_Number_Of_Channels
|
err = .Invalid_Number_Of_Channels
|
||||||
|
|||||||
Reference in New Issue
Block a user