empty png encode error

This commit is contained in:
Ryan Oldenburg 2021-01-11 11:45:59 -06:00
parent 3e85e0cc43
commit b60f262587

View file

@ -492,6 +492,11 @@ proc encodePng*(
proc encodePng*(image: Image): string = proc encodePng*(image: Image): string =
## Encodes the image data into the PNG file format. ## 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( cast[string](encodePng(
image.width, image.height, 4, image.data[0].addr, image.data.len * 4 image.width, image.height, 4, image.data[0].addr, image.data.len * 4
)) ))