Hi, A year ago I was writing basic Racket programs and I could save image as variable, like this: (define me [img])
Where [img] was an image and I could, of couse, see it in the source code file, or the user could put an save an image in "me" variable when the programs was running.
I tried to make this kindda type, but I couldn't.
how can I do such thing in Nim?
I don't know the precise how to do it, but you need to open your image file and encode it base64 the entire image file to embed it in your executable.
Or, you can save it in memory during the runtime without any need to encode it to base64.
For rendering the image, look for any lib that specifically does that to your image type.
Racket, or maybe it could be said that Dr.Racket, is whole development IDE. If you're going to code using any text editor, the process would be same.
I think this could be done as an emacs plugin. Emacs already has a mode that allows you to see paths to images as the image themself in the editor. iimage.el is the *mode* (emacs term) that controls the behavior of it. If you understand it, I think you can create a mode on your own that does exactly what you want. Or you find a way how this general solution applies to help your problem.
This will not show an image but you can embed binary data at compile time with something like this
import os, macros, base64 macro embed_binary_file(var_name:untyped,filename:string) : typed = let bin64 = base64.encode(slurp(filename.strVal)) result = newStmtList() result.add(newLetStmt(var_name,newStrLitNode(bin64))) embed_binary_file(img,"digits.bmp") echo("Image Data:" & $img)