For a couple of hours i've been trying to make this lib works in nim, but i dont know if it is just my ignorance (probably) or some problem in nim.
Im implementing this function https://github.com/lvandeve/lodepng/blob/master/lodepng.cpp#L4690-L4693 like this:
{.compile: "lodepng.c".}
proc lodepng_decode32(image: var ptr[cchar], width, height: var cuint, file: var cstring, insize: csize): cuint {.importc.}
Then i want to pass the data from a file like the following:
var img: ptr cchar= nil
var w, h: cuint = 0
var file = open("test.png") #Simple 8x8 image, 201 bytes
var data = readAll(file).cstring
let error = lodepngDecode32(img, w, h, data, getFileSize(file).csize)
But i'm getting the error: Error: unhandled exception: value out of range: 201 [RangeError]