Page 1 of 1

What format are screenshots written in?

Posted: Sun Sep 26, 2010 9:16 pm
by zac352
I used code similar to this:

Code: Select all

local sc=love.graphics.newScreenshot()
local f=love.filesystem.newFile("img.png")
f:open("w")
f:write(sc)
f:close()
But no matter which format I try (png, bmp, jpg, ...), it always comes out as corrupt...

Any help would be appreciated.

Re: What format are screenshots written in?

Posted: Sun Sep 26, 2010 9:38 pm
by Robin
Perhaps sc:getString()? I'm not sure how to do it right, but newScreenshot returns an ImageData. See below.

Re: What format are screenshots written in?

Posted: Sun Sep 26, 2010 9:40 pm
by CyaNox
Try something along the lines of:

Code: Select all

		s = love.graphics.newScreenshot()
		d = love.image.newEncodedImageData( s, "bmp" )
		success = love.filesystem.write( "screenshot.bmp", d)

Re: What format are screenshots written in?

Posted: Sun Sep 26, 2010 9:41 pm
by bartbes
ImageData is raw image data, so you probably want to encode it using EncodedImageData first, as said above.

Re: What format are screenshots written in?

Posted: Sun Sep 26, 2010 9:52 pm
by zac352
I was about to post about how I just found it here - http://love2d.org/wiki/love.image.newEncodedImageData, but you guys already covered it. Thanks. :awesome:

I love the rollover thing for :awesome: :rofl:

Re: What format are screenshots written in?

Posted: Sun Sep 26, 2010 9:54 pm
by zac352
You should add png. :P

Re: What format are screenshots written in?

Posted: Sun Sep 26, 2010 9:57 pm
by Robin

Re: What format are screenshots written in?

Posted: Sun Sep 26, 2010 10:01 pm
by zac352
It's a good thing you can make images - setting individual pixels in something like a chart = death by lag