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