Page 1 of 1

Problem writing a screenshot.

Posted: Sat May 26, 2012 1:03 pm
by 1u4
Hi, I'm having trouble writing with the newScreenshot() function.

Code: Select all

function love.load()
	love.filesystem.setIdentity("screenshot")
end

function love.draw()
	took = true
	screenshot = love.graphics.newScreenshot()
	if took then
		took = false
		imageData = screenshot:encode( "png" ) 
		love.filesystem.write( "ss.png", imageData, 500 )
	end
end
Why does imageData = screenshot:encode( "png" ) return nil? What am I doing wrong here?

Thanks.

Re: Problem writing a screenshot.

Posted: Sat May 26, 2012 1:41 pm
by bartbes
Read up on ImageData:encode again, you're using it incorrectly.

Re: Problem writing a screenshot.

Posted: Sun May 27, 2012 5:20 am
by Inny
This is what I use (as of 0.8.0)

Code: Select all

function saveScreenshot()
  local name = string.format("screenshot-%s.png", os.date("%Y%m%d-%H%M%S"))
  local shot = love.graphics.newScreenshot()
  shot:encode(name, "png")
end