Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compiletime decoder #44

Open
sv-keller opened this issue May 9, 2020 · 2 comments
Open

compiletime decoder #44

sv-keller opened this issue May 9, 2020 · 2 comments

Comments

@sv-keller
Copy link

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")

@jangko
Copy link
Owner

jangko commented May 13, 2020

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?

@sv-keller
Copy link
Author

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants