[Solved] Nothing happen with imageData:encode()

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
Popolon
Prole
Posts: 25
Joined: Mon Nov 07, 2016 11:03 am
Location: France/Paris

[Solved] Nothing happen with imageData:encode()

Post 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
Last edited by Popolon on Tue Apr 26, 2022 7:52 pm, edited 1 time in total.
User avatar
GVovkiv
Party member
Posts: 686
Joined: Fri Jan 15, 2021 7:29 am

Re: Nothing happen with imageData:encode()

Post by GVovkiv »

Are you sure about that?
Code produced that file:
test.png
test.png (752 Bytes) Viewed 2602 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?
User avatar
Popolon
Prole
Posts: 25
Joined: Mon Nov 07, 2016 11:03 am
Location: France/Paris

Re: Nothing happen with imageData:encode()

Post 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
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 13 guests