empty png encode error
This commit is contained in:
parent
3e85e0cc43
commit
b60f262587
1 changed files with 5 additions and 0 deletions
|
@ -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
|
||||||
))
|
))
|
||||||
|
|
Loading…
Reference in a new issue