mirror of https://github.com/status-im/nimPNG.git
fix apidoc
This commit is contained in:
parent
47cd1e5754
commit
75640f72e9
|
@ -42,7 +42,7 @@ install:
|
|||
- SET "NEED_REBUILD="
|
||||
|
||||
- IF NOT EXIST "Nim\\.git\\" (
|
||||
git clone https://github.com/nim-lang/Nim.git
|
||||
git clone --depth 1https://github.com/nim-lang/Nim.git
|
||||
) ELSE (
|
||||
( cd Nim ) &
|
||||
( git pull ) &
|
||||
|
@ -80,7 +80,7 @@ install:
|
|||
|
||||
build_script:
|
||||
- cd C:\projects\%APPVEYOR_PROJECT_SLUG%
|
||||
- nimble install -y # > nul
|
||||
- nimble install -y > nul
|
||||
test_script:
|
||||
- nimble tests
|
||||
|
||||
|
|
20
apidoc.md
20
apidoc.md
|
@ -37,7 +37,8 @@ decodePNG24(input: string, settings = PNGDecoder(nil)): PNGResult
|
|||
|
||||
|
||||
```Nim
|
||||
# generic version accept T = `string`, `seq[uint8]`
|
||||
# generic version accept T = `string`, `seq[TT]`, or openArray[TT]
|
||||
# TT can be `byte`, `char`, or `uint8`
|
||||
encodePNG(input: T, w, h: int, settings = PNGEncoder(nil)): PNG[T]
|
||||
encodePNG(input: T, colorType: PNGColorType, bitDepth, w, h: int, settings = PNGEncoder(nil)): PNG[T]
|
||||
encodePNG32(input: T, w, h: int): PNG[T]
|
||||
|
@ -65,7 +66,7 @@ when not defined(js):
|
|||
saveAPNG(png: PNG[T], fileName: string): PNGStatus
|
||||
|
||||
decodePNG(T: type, s: Stream, colorType: PNGColorType, bitDepth: int, settings = PNGDecoder(nil)): PNGResult[T]
|
||||
decodePNG(T: type, s: Stream, settings = PNGDecoder(nil)): PNG
|
||||
decodePNG(T: type, s: Stream, settings = PNGDecoder(nil)): PNG[T]
|
||||
|
||||
type
|
||||
PNGRes*[T] = Result[PNGResult[T], string]
|
||||
|
@ -82,7 +83,18 @@ decodePNG24(input: T, settings = PNGDecoder(nil)): PNGRes[T]
|
|||
## How to use PNGRes?
|
||||
|
||||
```Nim
|
||||
let res = loadPNG32(seq[uint8], fileName, settings)
|
||||
if res.isOk: result = res.get() # get PNGResult[seq[uint8]]
|
||||
type
|
||||
PNGPix = seq[uint8]
|
||||
|
||||
var pix: PNGResult[PNGPix]
|
||||
let res = loadPNG32(PNGPix, fileName)
|
||||
if res.isOk: pix = res.get() # get PNGResult[PNGPix]
|
||||
else: debugEcho res.error() # get error string
|
||||
|
||||
# now you can access PNGResult as usual:
|
||||
debugEcho "width: ", pix.width
|
||||
debugEcho "height: ", pix.height
|
||||
|
||||
# draw(pix.data)
|
||||
# or drawFrames(pix.frames) if it is a APNG
|
||||
```
|
||||
|
|
|
@ -89,9 +89,9 @@ to create PNG:
|
|||
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
|
||||
* 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:
|
||||
pixels are stored as raw bytes using Nim's `string`/`seq[T]` as container:
|
||||
|
||||
| Byte Order | Format |
|
||||
|:------------------------------:|:----------------:|
|
||||
|
@ -100,7 +100,6 @@ pixels are stored as raw bytes using Nim's string as container:
|
|||
| grey1,grey2,grey3, ..., greyn | GREY 8 bit |
|
||||
| grey1,a1,grey2,a2,...,greyn,an | GREY ALPHA 8 bit |
|
||||
|
||||
|
||||
## Animated PNG (APNG)
|
||||
|
||||
Since version 0.2.0, nimPNG provides support for [Animated PNG](https://en.wikipedia.org/wiki/APNG).
|
||||
|
@ -126,7 +125,7 @@ Right now nimPNG is just a PNG encoder/decoder.
|
|||
|
||||
The usual loadPNG and decodePNG can decode both unanimated and animated PNG.
|
||||
`png.width`, `png.height`, `png.data` works as usual. If the decoded PNG is an APNG, `png.data` will contains default frame.
|
||||
Animation frames can be accessible via `png.frames`. If it is not an APNG, `png.frames` will be nil.
|
||||
Animation frames can be accessible via `png.frames`. If it is not an APNG, `png.frames` will be have zero length.
|
||||
|
||||
### Encoding
|
||||
|
||||
|
@ -156,7 +155,7 @@ the default image will be part of the animation. If `ctl` is nil, default image
|
|||
var str = png.encodeAPNG()
|
||||
```
|
||||
|
||||
* Final step is to call `saveAPNG` if you want save it to file or call `encodeAPNG` if you want to get the result in a string container
|
||||
* Final step is to call `saveAPNG` if you want save it to a file or call `encodeAPNG` if you want to get the result in memory.
|
||||
|
||||
You can read the details of frame control from [spec](https://wiki.mozilla.org/APNG_Specification).
|
||||
You can also see an example in tester/test.nim -> generateAPNG
|
||||
|
|
Loading…
Reference in New Issue