Closed Lecale closed 4 years ago
I usually get that error from STBI when I supply the wrong path. Are you sure you can open the file?
discard readFile("C:\\Nim\\NimExamples\\MyRecipes\\a.png")
work?
Are you sure its a png file? STBI can't open some png files what are odd like monochrome ...
Does it work with png files in the test folder?
The same exception accurred on Windows 10 (64): Nim Compiler Version 1.0.4 [Windows: i386] MinGW32 from Nim official site
Tested with fillCirle.png in the test folder and made sure the path was correct by:
doAssert img.fileExists
May be a link issue:
https://gitlab.com/define-private-public/stb_image-Nim/issues/8
This issue can be solved by adding cdecl
to stb_... procs:
# Internal functions
proc stbi_write_png(
filename: cstring;
w, h, comp: cint;
data: pointer,
stride_in_bytes: int
): cint
{.importc: "stbi_write_png",cdecl.}
As jangko said on Nim forum:
depends on your C compiler configuration, most of the times you need to specify the calling convention explicitly, for example: stdcall for msvc or cdecl for gcc
in your case, try add cdecl:
proc addTwoIntegers(a, b: cint): cint {.importc,cdecl.}
I switched to using https://github.com/jangko/nimPNG which has no C code. Does this work for you now?
The nimPNG based version of flippy works for me and now it supports Unicode file names on Windows(Using MinGW)
When trying to use fllippy to minify an image I keep getting an error on
How did I call?
var a = reduceImage("C:\\Nim\\NimExamples\\MyRecipes\\a.png", "C:\\Nim\\NimExamples\\MyRecipes\\b.png", 3)
against procIs it my own stupidity, or is it a real issue? I am on windows as you probably guessed.