Open NevsDev opened 4 years ago
Have you ever tried this?
never, nimPNG not designed to run at compiletime.
Is it possible to implement a compiletime decoder as well?
it is possible, but require perhaps 80% change in the source code.
Are there any known hurdles or problems?
nimPNG is using var param
everywhere and use it in complex algorithm. Nim VM have a bug that can mutate var param depends on how you arrange the code. There is no guarantee it will always work like runtime version.
Next big hurdle is nimPNG use a lot of cast between different size integer. It is possible to do that in Nim VM, as demonstrated in stint, but also require large scale changes in the source code.
Why you need compile time decoder? what is your use case?
In my case I embed resources into the code.
Currently I store the data as string:
const res = staticRead("filename")
var decodedRes = decodePNG...(res)
Of course, this has the advantage that the compressed image is smaller, but slows down the start time. ...
But I also thought about the possibilities of such a decoder: for example, during compile time you could also edit images or adjust them to a certain version of build. I think that the compiletime decoder has a small priority, but there are useful areas for this decoder and I would like to use them :)
Hello janko
first: I like your repository and the simplicity of the api very much.
Questions: Is it possible to implement a compiletime decoder as well? Are there any known hurdles or problems? Have you ever tried this?
possible new API could be:
const png = loadStaticPNG32("image.png")