Is it possible to save a canvas in a form of an image?
If so, how?
saving a canvas as an image
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: saving a canvas as an image
canvas:getImageData():encode(filename)
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: saving a canvas as an image
thank you, have a nice dayNixola wrote:canvas:getImageData():encode(filename)
-
- Prole
- Posts: 23
- Joined: Sat Jun 17, 2017 1:23 pm
Re: saving a canvas as an image
I can save image to "1.png" like this?
canvas need to change name used canvas?
GAMEWINDOWCANVAS:getImageData():encode(filename)
ERROR!! attempt to call a nil value
i have canvas with gamefield named GAMEWINDOWCANVAS
how to save it using this command ?
i trying just canvas like in a original but it doesn't work
canvas of course exists and works
canvas need to change name used canvas?
GAMEWINDOWCANVAS:getImageData():encode(filename)
ERROR!! attempt to call a nil value
i have canvas with gamefield named GAMEWINDOWCANVAS
how to save it using this command ?
i trying just canvas like in a original but it doesn't work
canvas of course exists and works
Last edited by dj--alex@ya.ru on Sat May 04, 2019 10:06 pm, edited 1 time in total.
Re: saving a canvas as an image
If you're using any version after 0.10, the function is called newImageData, not getImageData.
-
- Prole
- Posts: 23
- Joined: Sat Jun 17, 2017 1:23 pm
Re: saving a canvas as an image
love.filesystem.setIdentity('realpath');
GAMEWINDOWCANVAS:newImageData():encode('png', realpath..levelname.. 'x2.png');
Thanks but
why it ignore realpath if i add it to filename?
realpath interpreted incorrect
/home/alex/.local/share/love/home/alex/Games/M2K/usr/bin/saves/m2ksavex
Im use 0.10.2 but Android packager limits me to 0.10.2 for forever.
i need to save files here
/home/alex/Документы/R-M2K/M2K_GAME_FOLDER/usr/bin/saves
image with savemage MUST be with folder with savegame...
and i get canvas image here
/home/alex/.local/share/love/m2k
GAMEWINDOWCANVAS:newImageData():encode('png', realpath..levelname.. 'x2.png');
Thanks but
why it ignore realpath if i add it to filename?
realpath interpreted incorrect
/home/alex/.local/share/love/home/alex/Games/M2K/usr/bin/saves/m2ksavex
Im use 0.10.2 but Android packager limits me to 0.10.2 for forever.
i need to save files here
/home/alex/Документы/R-M2K/M2K_GAME_FOLDER/usr/bin/saves
image with savemage MUST be with folder with savegame...
and i get canvas image here
/home/alex/.local/share/love/m2k
-
- Prole
- Posts: 23
- Joined: Sat Jun 17, 2017 1:23 pm
Re: saving a canvas as an image
no answer.
maybe this impossible direct save file to folder with game with lua commands.
\
maybe this impossible direct save file to folder with game with lua commands.
\
- zorg
- Party member
- Posts: 3465
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: saving a canvas as an image
Apart from the necro-posting you performed previously, yes, the encode function can only save to the save folder like literally all other löve related functions.
Also, forget about the realpath, you don't need to use it, it's already relative to the save folder.
GAMEWINDOWCANVAS:newImageData():encode('png', levelname.. 'x2.png')
That should do what you want... but then again, it's android, it may just not work at all.
Also, forget about the realpath, you don't need to use it, it's already relative to the save folder.
GAMEWINDOWCANVAS:newImageData():encode('png', levelname.. 'x2.png')
That should do what you want... but then again, it's android, it may just not work at all.
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: saving a canvas as an image
We can move encoded (saved) image file by os.rename(src, dst)
Science and violence
-
- Prole
- Posts: 23
- Joined: Sat Jun 17, 2017 1:23 pm
Re: saving a canvas as an image
to zorg
you don't understang
game already save game in special folder inside GAME folder,
i just want to save image with savegame folder.
i don't like ideology with "my documents" folder. good old games always do save in their folders.
to HDPLocust
for save game i use
file=love.filesystem.write(realfilename, data)
and it always works.
copy image from screenshot "zone" to destination - really no another methods?
i still hope, maybe found normal command like
canvas:saveimage(realpath,".png)...
i just need get png and redirect it as "data"
you don't understang
game already save game in special folder inside GAME folder,
i just want to save image with savegame folder.
i don't like ideology with "my documents" folder. good old games always do save in their folders.
to HDPLocust
for save game i use
file=love.filesystem.write(realfilename, data)
and it always works.
copy image from screenshot "zone" to destination - really no another methods?
i still hope, maybe found normal command like
canvas:saveimage(realpath,".png)...
i just need get png and redirect it as "data"
Last edited by dj--alex@ya.ru on Thu May 09, 2019 7:01 pm, edited 1 time in total.
Who is online
Users browsing this forum: Google [Bot] and 1 guest