Page 1 of 1

[Solved] Nothing happen with imageData:encode()

Posted: Tue Apr 26, 2022 6:16 pm
by Popolon
Here is a simple example about how to output picture to a png file (in 0.11+), after what I read, the exemple on the wiki is not clear, and didn't found anything, but some that tried before 0.11.

I use LÖVE 0.11.4, nothing happen, no file created, no error, rights to write.

Code: Select all

function love.load()
  canvas = love.graphics.newCanvas(800,600)
  love.graphics.setCanvas(canvas)
  love.graphics.circle("fill",200,200,100)
  -- need to set another Canvas to avoid Canvas:newImageData cannot be called while that Canvas is currently active.
  love.graphics.setCanvas()
  imagedata = canvas:newImageData()
  imagedata:encode("png","test.png")
end

function love.draw()
end

Re: Nothing happen with imageData:encode()

Posted: Tue Apr 26, 2022 6:28 pm
by GVovkiv
Are you sure about that?
Code produced that file:
test.png
test.png (752 Bytes) Viewed 2554 times
If you under linux, this code should produce file under ~/.local/share/love/lovegame
Check save directory one more time (https://love2d.org/wiki/love.filesystem), perhaps you missed it there?

Re: Nothing happen with imageData:encode()

Posted: Tue Apr 26, 2022 6:37 pm
by Popolon
Thank for your answer, nothing either in ~/.local/share/love/lovegame/

Tga as no effect either, but I found it, thanks !!!

I run the main.love from /tmp directory for this exemple, like this:

Code: Select all

cd /tmp/
love .
and it was here:
~/.local/share/love/tmp/test.png

Tested the tga for information, and nothing happened in the directory, but I don' care here.

Your solution worked anf for for my tool too :)
so the path is
~/.local/share/love/<name_of_the_game_archive_or_dir>/test.png