Page 1 of 1

The image of the save the screenshot is reversal

Posted: Sat Jun 11, 2011 2:02 pm
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

Re: The image of the save the screenshot is reversal

Posted: Sat Jun 11, 2011 2:35 pm
by Robin
It is a bug, I think it is fixed in the next version of LÖVE.

Re: The image of the save the screenshot is reversal

Posted: Sat Jun 11, 2011 2:54 pm
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