Open ftsf opened 2 years ago
please report this to Nim repo as a regression. it is very hard to fix it from nimPNG.
Hmm, I've just gone and tested this with Nim 1.4 and Nim 1.2 and get the same behaviour, so it seems this is not caused by a recent change in Nim.
Testing using a cutdown example doesn't reproduce the problem.
import nimPNG
import os
import strformat
import strutils
import times
import sdl2_nim/sdl
var swCanvas32: Surface
var writePath = "."
proc saveScreenshot*() =
echo "saveScreenshot"
createDir(writePath & "/screenshots")
let filename = joinPath(writePath, joinPath("screenshots", "screenshot-$1T$2.png".format(getDateStr(), getClockStr())))
var data = newSeq[uint8](swCanvas32.w * swCanvas32.h * 4)
copyMem(data[0].addr, swCanvas32.pixels, swCanvas32.w * swCanvas32.h * 4)
var res = savePNG(filename, data, LCT_RGBA, 32, swCanvas32.w, swCanvas32.h)
echo "saved screenshot to: ", filename
saveScreenshot()
Compiles successfully, but similar code used in nico gives the original error, though I'm unsure why, will investigate further.
looks like a global scope pollution to me. some inner template in filters.nim
might collide with other template from somewhere.
a workaround is, you can write a helper module+proc to force instantiate nimPNG generics and then reexport those non-generic proc.
Nim Compiler Version 1.6.0 [Windows: amd64]
results in: