What format are screenshots written in?

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
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

What format are screenshots written in?

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

Re: What format are screenshots written in?

Post by Robin »

Perhaps sc:getString()? I'm not sure how to do it right, but newScreenshot returns an ImageData. See below.
Last edited by Robin on Sun Sep 26, 2010 9:48 pm, edited 1 time in total.
Help us help you: attach a .love.
User avatar
CyaNox
Prole
Posts: 22
Joined: Thu Feb 11, 2010 6:11 pm

Re: What format are screenshots written in?

Post 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)
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: What format are screenshots written in?

Post by bartbes »

ImageData is raw image data, so you probably want to encode it using EncodedImageData first, as said above.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: What format are screenshots written in?

Post 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:
Hello, I am not dead.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: What format are screenshots written in?

Post by zac352 »

You should add png. :P
Hello, I am not dead.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: What format are screenshots written in?

Post by Robin »

Help us help you: attach a .love.
User avatar
zac352
Party member
Posts: 496
Joined: Sat Aug 28, 2010 8:13 pm
Location: In your head.
Contact:

Re: What format are screenshots written in?

Post by zac352 »

It's a good thing you can make images - setting individual pixels in something like a chart = death by lag
Hello, I am not dead.
Post Reply

Who is online

Users browsing this forum: No registered users and 88 guests