[SOLVED] Saving images problem

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
alesan99
Citizen
Posts: 53
Joined: Sun Feb 09, 2014 3:13 am
Contact:

[SOLVED] Saving images problem

Post by alesan99 »

Hey guys, this is my first post here :awesome:.
I've been using love2d for a quite while now so I'm familiar with all the basic stuff.

Im working on an image editor with LOVE 0.9.0 and I've got the drawing down.
Now I want to be able to save the image.
This is how I'm doing it:

Code: Select all

image = "img.png"
...
imgdata = love.image.newImageData(image)
...
love.filesystem.write("test.png", imgdata)
It makes the file but the .png doesn't show the image, it gets corrupted.
I could use love.filesystem.read instead but I need to be able to use setPixel and getPixel.

So i'd be great if there's a solution that doesn't require me to rewrite the entire thing.

Here's the .love
alesan99_paint.love
(4.46 KiB) Downloaded 88 times
Controls
Press 1 to save

left click to draw
right click to get the color of the pixel your mouse is on
hold space and use your mouse to drag the image
Last edited by alesan99 on Sun Feb 09, 2014 1:48 pm, edited 1 time in total.
User avatar
slime
Solid Snayke
Posts: 3144
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: Saving images problem (image editor)

Post by slime »

You can use [wiki]ImageData:encode[/wiki] to save an image to disk as either png, jpg, or tga. :)
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 2 guests