mirror of
https://github.com/odin-lang/Odin.git
synced 2026-11-05 18:23:18 -05:00
`core:image/png`: - New `save` (`save_to_buffer`, `save_to_file`) - Supports G, GA, RGB, RGBA in 8 and 16 bit per channel. - Writes IHDR, one IDAT and IEND; metadata is left for a later PR. - Defaults: Deflate level 5 and the `.Adaptive` per-row filter heuristic. - `.None`, `.Sub`, `.Up`, `.Average` or `.Paeth` also available. - Speed at the defaults: about 85 MB/s (5950X) and 110 MB/s (M4) of raw pixels; Deflate is about 95% of that time. - Size: on 16-bit RGBA test images the default is 3-12% smaller than libpng's default level 6. Level 9 matches libpng -9 to the byte on the 1024x1024 Odin logo. - Fix: paletted images with `tRNS` loaded with only `.alpha_premultiply` returned 4 channels of packed RGB. - Fix: premultiplied palette entries passed `blend` its arguments in the wrong order, turning opaque entries black. `core:image`: - Helper procedures move from `common.odin` to `helpers.odin`. - New typed pixel views: `to_gray`, `to_ga`, `to_rgb`, `to_rgba` and their 16-bit variants, taking a `^image.Image`, and returning e.g. `[]RGB_Pixel`. - Fix: `return_single_channel` used the 1-based `Channel` as a 0-based index, so R returned G and A read past the pixel. - Fix: `blend` swapped its weights and masked instead of shifting, so it was only right at alpha 0 and 255.