Creating Image(s) on the fly

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
chrism
Prole
Posts: 21
Joined: Wed May 25, 2011 6:17 pm

Creating Image(s) on the fly

Post by chrism »

Is it possible to create Image objects on the fly and draw/blt on them? I could be missing something obvious here; I see there is love.image.newImageData, but it's unclear to me how you can draw or blit onto that image. Thanks.
User avatar
Kadoba
Party member
Posts: 399
Joined: Mon Jan 10, 2011 8:25 am
Location: Oklahoma

Re: Creating Image(s) on the fly

Post by Kadoba »

Sort of.

Framebuffers would be best suited for what you're describing. Although framebuffers tend to break older hardware.

Alternatively if you really, really want to use images you can save the image data when you load it and then just paste what you want into a screen-sized image data and then turn it into an image and draw it. That is probably a bit slow though depending on your screen scaling and resolution.
User avatar
BlackBulletIV
Inner party member
Posts: 1261
Joined: Wed Dec 29, 2010 8:19 pm
Location: Queensland, Australia
Contact:

Re: Creating Image(s) on the fly

Post by BlackBulletIV »

There are two ways to draw to ImageData objects. You can play with individual pixels, in which case ImageData:setPixel, ImageData:mapPixel, and ImageData:getPixel are your friends. You can also paste other ImageData objects into an ImageData object using ImageData:paste.
chrism
Prole
Posts: 21
Joined: Wed May 25, 2011 6:17 pm

Re: Creating Image(s) on the fly

Post by chrism »

BlackBulletIV wrote:There are two ways to draw to ImageData objects. You can play with individual pixels, in which case ImageData:setPixel, ImageData:mapPixel, and ImageData:getPixel are your friends. You can also paste other ImageData objects into an ImageData object using ImageData:paste.
This might be good enough for my current purposes. Thanks. It would be great if the "draw" functions in love.graphics were replicated for images as well...
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: Creating Image(s) on the fly

Post by bartbes »

Framebuffers exist for this very reason.
Post Reply

Who is online

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