Added optional buffer for image Read()

This commit is contained in:
Alex Eidt 2022-04-22 14:17:39 -07:00
parent 9f884aeec1
commit 84476c3206
4 changed files with 63 additions and 6 deletions

View file

@ -136,7 +136,13 @@ For the `SetFrameBuffer()` method, the `buffer` parameter must have a length of
## Images
Vidio provides some convenience functions for reading and writing to images using an array of bytes. Currently, only `png` and `jpeg` formats are supported.
Vidio provides some convenience functions for reading and writing to images using an array of bytes. Currently, only `png` and `jpeg` formats are supported. When reading images, an optional `buffer` can be passed in to avoid array reallocation.
```go
Read(filename string, buffer ...[]byte) (int, int, []byte, error)
Write(filename string, width, height int, buffer []byte) error
```
```
```go
w, h, img, err := vidio.Read("input.png")