Problem writing a screenshot.

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
User avatar
1u4
Prole
Posts: 16
Joined: Tue May 01, 2012 6:27 am
Location: Oh no, not Finland!

Problem writing a screenshot.

Post by 1u4 » Sat May 26, 2012 1:03 pm

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.
There is a story of a farmer whose horse ran away. That evening the neighbors gathered to commiserate with him since this was such bad luck.
He said, "May be." Continued...

User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Problem writing a screenshot.

Post by bartbes » Sat May 26, 2012 1:41 pm

Read up on ImageData:encode again, you're using it incorrectly.

User avatar
Inny
Party member
Posts: 652
Joined: Fri Jan 30, 2009 3:41 am
Location: New York

Re: Problem writing a screenshot.

Post by Inny » Sun May 27, 2012 5:20 am

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

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 6 guests