Page 1 of 1

save a screenshot is not working, why?

Posted: Mon Oct 24, 2011 7:47 am
by Nubeh
Hi,
I'm trying to simply save a screenshot in a bmp image. I'm listening to a mouse click to take the screenshot and I'm executing:

local s = love.graphics.newScreenshot() --ImageData
local d = love.image.newEncodedImageData(s, "bmp")
local success = love.filesystem.write("pic.bmp", d)

but I get the following error:

'Data could not be written'

I also tried to set the identity to a 'sheet' folder but it's not working. I've also tried to use the :encode("bmp") function instead of newEncodedImageData but it's not working. Any idea what I do wrong?

note: I'm dragging and dropping my folder on a shortcut of love.exe, but that should not be a problem right?



thanks for the help!

Re: save a screenshot is not working, why?

Posted: Mon Oct 24, 2011 10:30 pm
by Boolsheet
The code you pasted should work. It's possible that the configuration of your system prevents LÖVE to write in the %APPDATA% path, but that's just a guess.
Can you show us how you set the identity?

Re: save a screenshot is not working, why?

Posted: Tue Oct 25, 2011 6:39 am
by Nubeh
Thanks for the answer! ;)
I have this conf.lua file that sets the identity:

function love.conf(t)
t.screen.width = 1000
t.screen.height = 680
t.identity = "sheets"
t.console = true
end

my goal is to have the images saved inside the sheets folder. Can I redirect the image to a folder outside the APPDATA one? How can I check the privileges of LÖVE on the APPDATA folder?

thanks

Re: save a screenshot is not working, why?

Posted: Tue Oct 25, 2011 9:20 am
by Robin
Please give us a .love, as the rules describe. Read how to make a .love file here. This way we can help you better and more quickly.

Re: save a screenshot is not working, why?

Posted: Tue Oct 25, 2011 11:39 am
by Nubeh
I found out that by using the admin user on my PC the code actually works. Strange that the LOVE program doesn't have the access to write in the APPDATA folder when I use my other user.

Sorry I couldn't post a .love file but I'd have some images that I use in the code that I can't publish.

Problem solved then. I'd like to save it in a .png though...when is LOVE 0.8 coming out?

thanks for the help! ;)