I have run into an issue that totally stumped me . I wanted to create a small class to convert a bitmap to an array of pixels. The bitmap is created through an absolute pathname, and the pathname I input (on a Windows10 OS) is
let path = "D:\Dev\images\test"
but, I suspect this happens at compile time , the string is formatted like this
"D:\\Dev\\images\test"
and of course it kills the program immediately. I am 99.9% sure that this is something going on with the IDE that I am forgetting. Adding @ at the beginning of the pathname or a double \ doesn't seem to do anything. I am totally stumped on what to do.
Edit: I have expressed myself rather poorly. By "Adding @ at the beginning of the pathname or a double \ doesn't seem to do anything" i mean that I tried both adding @ at the beginning outside of the string :
@"D:\Dev\images\test" and "D:\\Dev\\images\\test"both produce the same result displayed above, except for the fact that D:\\Dev\\images\\test produces an exact copy of itself, but it's still invalid by Win10 standards.
Finally , the error raised is a generic "invalid parameter". No code whatsoever modifies the path value. It is , in fact , the first instruction in main.
let main _ =
let path = Defaults.img_folder + "\\test" //img_folder = "D:\\Dev\\images"
let f = new Bitmap(path) //throws "invalid parameter" error here
let spr_img : pixel[,] = (Array2D.init
f.Width
f.Height
(fun x y -> new pixel(Defaults.full_cover , ConsoleColor_from_Color(f.GetPixel(x , y)) , Defaults.backgroundcolor)) )
let eng = new engine(w , h)
eng.create_and_register_sprite(new image(spr_img), 20 , 20 , 0)
eng.loop_on_key(
{
speed = 0.
positionX = 20.
positionY = 20.
positionZ = 20.
quitting = false
},
updater //external function
)
0