From b60f2625871253055cfd137652a5c916d62d9db1 Mon Sep 17 00:00:00 2001 From: Ryan Oldenburg Date: Mon, 11 Jan 2021 11:45:59 -0600 Subject: [PATCH] empty png encode error --- src/pixie/fileformats/png.nim | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/pixie/fileformats/png.nim b/src/pixie/fileformats/png.nim index eb43363..67c3b62 100644 --- a/src/pixie/fileformats/png.nim +++ b/src/pixie/fileformats/png.nim @@ -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 ))