diff --git a/readme.md b/readme.md index 03a68e4..aae1548 100644 --- a/readme.md +++ b/readme.md @@ -58,26 +58,33 @@ let png = loadPNG32("image.png") #png.data -> pixels data in RGBA format ``` -if you already have the whole file in memory +if you already have the whole file in memory: + +```nimrod let png = decodePNG32(raw_bytes) -will do the same as above +#will do the same as above +``` other variants: -loadPNG24 -> will produce pixels in RGB format 8 bpp -decodePNG24 -> load png from memory instead of file + +* loadPNG24 -> will produce pixels in RGB format 8 bpp +* decodePNG24 -> load png from memory instead of file to create PNG: -savePNG32("output.png", rgba_pixels, width, height) -or savePNG24 -encodePNG32(rgba_pixels, width, height) -or encodePNG24 -use **loadPNG** or **savePNG** if you need specific input/output format by supplying supported **colorType** and **bitDepth** information. Use **encodePNG** or **decodePNG** to do in memory encoding/decoding by supplying desired colorType and bitDepth information +* savePNG32("output.png", rgba_pixels, width, height) or savePNG24 +* encodePNG32(rgba_pixels, width, height) or encodePNG24 -pixels are stored as raw bytes using Nim's string as container. -r1,g1,b1,a1,r2,g2,b2,a1,...,rn,gn,bn,an -> RGBA format 8 bit -r1,g1,b1,r2,g2,b2,...,rn,gn,bn -> RGB format 8 bit -grey1,grey2,grey3, ..., greyn -> GREY format 8 bit -grey1,alpha1,grey2,alpha2,...,greyn,alphan -> GREY ALPHA format 8 bit +special notes: +* Use **loadPNG** or **savePNG** if you need specific input/output format by supplying supported **colorType** and **bitDepth** information. +* Use **encodePNG** or **decodePNG** to do *in-memory* encoding/decoding by supplying desired colorType and bitDepth information +pixels are stored as raw bytes using Nim's string as container: + +| Byte Order | Format | +|:------------------------------:|:----------------:| +| r1,g1,b1,a1,...,rn,gn,bn,an | RGBA 8 bit | +| r1,g1,b1,r2,g2,b2,...,rn,gn,bn | RGB 8 bit | +| grey1,grey2,grey3, ..., greyn | GREY 8 bit | +| grey1,a1,grey2,a2,...,greyn,an | GREY ALPHA 8 bit |