The image of the save the screenshot is reversal

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
poorenglish
Prole
Posts: 47
Joined: Thu Sep 24, 2009 1:49 pm

The image of the save the screenshot is reversal

Post by poorenglish »

screenshot =love.graphics.newScreenshot()
filedate = love.image.newEncodedImageData(screenshot,"tga")
success = love.filesystem.write( "image.tga", filedate)
found the image.tga is reversal,change the image format to "bmp",also the image.bmp is reversal.
Is this a issue or by design?
THK
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: The image of the save the screenshot is reversal

Post by Robin »

It is a bug, I think it is fixed in the next version of LÖVE.
Help us help you: attach a .love.
User avatar
Boolsheet
Inner party member
Posts: 780
Joined: Wed Dec 29, 2010 4:57 am
Location: Switzerland

Re: The image of the save the screenshot is reversal

Post by Boolsheet »

The issue has not been resolved yet. There's a chance that DevIL gets dropped for 0.8.0 and the issue fixes itself. ;)
Edit: It's fixed in 0.8.0.

In the meantime you could use a cheap workaround. Not all ImageData are affected by this origin problem. It will be correct for images loaded from encoded formats. To exploit this you have to create a dummy image with the width and height of your original image and then paste it over the new image:

Code: Select all

function forceTopLeftOrigin(img)
	local imgWidth, imgHeight = img:getWidth(), img:getHeight()
	local PBM = string.format("P4\n%d %d\n%s", imgWidth, imgHeight, ("\255"):rep(math.ceil(imgWidth*imgHeight/8)))
	
	local imgFile = love.filesystem.newFileData(PBM, "temp.pbm", "file")
	local newImg = love.image.newImageData(imgFile)
	
	newImg:paste(img, 0, 0, 0, 0, imgWidth, imgHeight)
	
	return newImg
end
The function returns a new ImageData that you can use the encode on.
That's of course not really fast. :P
Shallow indentations.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests