Merge pull request #47 from guzba/master

empty png encode error
This commit is contained in:
treeform 2021-01-11 09:55:53 -08:00 committed by GitHub
commit 9a4c45e282
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -492,6 +492,11 @@ proc encodePng*(
proc encodePng*(image: Image): string =
## Encodes the image data into the PNG file format.
if image.data.len == 0:
raise newException(
PixieError,
"Image has no data (are height and width 0?)"
)
cast[string](encodePng(
image.width, image.height, 4, image.data[0].addr, image.data.len * 4
))