save a screenshot is not working, why?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Nubeh
Prole
Posts: 3
Joined: Sat May 21, 2011 2:46 pm

save a screenshot is not working, why?

Post 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!
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: save a screenshot is not working, why?

Post 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?
Shallow indentations.
Nubeh
Prole
Posts: 3
Joined: Sat May 21, 2011 2:46 pm

Re: save a screenshot is not working, why?

Post 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
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: save a screenshot is not working, why?

Post 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.
Help us help you: attach a .love.
Nubeh
Prole
Posts: 3
Joined: Sat May 21, 2011 2:46 pm

Re: save a screenshot is not working, why?

Post 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! ;)
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 7 guests