ImageData rotate and scale

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
sutech
Prole
Posts: 2
Joined: Wed Jul 07, 2010 11:32 pm

ImageData rotate and scale

Post by sutech »

Is there a way to rotate and scale an ImageData I want to paste into another ImageData?

I want to create sprites from bunch of building blogs. Like a varied animated characters that would be build from few blocks like shoes, pants, torso, etc. without having to create each building block in various rotations.

I could create huge amount of sprites with little work this way.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: ImageData rotate and scale

Post by Robin »

Not that I'm aware of right away, but I think you could try using Quads, and using the love.graphics.push/translate/rotate/.../pop functions. Somebody please correct me. :P

{Edit: see http://love2d.org/wiki/love.graphics.push and friends}
Help us help you: attach a .love.
User avatar
Luiji
Party member
Posts: 396
Joined: Mon May 17, 2010 6:59 pm

Re: ImageData rotate and scale

Post by Luiji »

Yeah, I've been trying to do a similar thing with Boxdude, trying to take a single Boxdude graphic and rotating it in the varying directions to save file space, increasing load time as a sacrifice. Just transforming every time causes slowdown when you aren't looking in the correct direction.
Good bye.
pekka
Party member
Posts: 206
Joined: Thu Jan 07, 2010 6:48 am
Location: Oulu, Finland
Contact:

Re: ImageData rotate and scale

Post by pekka »

Transformations like rotation and scaling are only possible if you draw on the screen. In a future version of LÖVE you may also be able to draw into a non-visible frame buffer with the usual love.graphics.draw() operations, but we don't have that feature yet. So, with ImageData, we're stuck with the block copying operation and setting individual pixels.

It seems you only have two options for now.

1: Roll your own rotation and scaling code. There are plenty of examples to get you started; just do a web search. Doing this in pure Lua is not necessarily too slow: at least you should try it to see how fast you can make it go.

2: Actually draw on the screen, take a screen shot and read the pixels from the image data. This is obviously clumsy and visible to the user, but it might work well enough for some purposes.

Outside of LÖVE, you can also use image manipulation programs and APIs. I've found ImageMagick[1] to be quite useful. You could write simple shell or Lua scripts to drive it, and create a lot of images automatically. Of course, in this situation you are limited by the space all the images are going to take, since you would be creating them all in advance.

[1]: http://www.imagemagick.org/script/index.php

(Others might prefer GraphicsMagick to the above program. I sadly found it did not render certain SVG features very nicely yet (last time I tried, several months ago), so I was not fully happy with it. But you might want to try both anyway.)
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: ImageData rotate and scale

Post by kikito »

I'm with pekka on this one.

Use your graphic's program "rotate" or, if you need some kind of automation, go with imagemagick for now.

In any case, you will probably need to go over the generated images anyway in order to fix some of them.
When I write def I mean function.
User avatar
Luiji
Party member
Posts: 396
Joined: Mon May 17, 2010 6:59 pm

Re: ImageData rotate and scale

Post by Luiji »

Hm...I'm going to try out the screenshot technique. I could have it so that on the Luiji Games Unincorporated screen that the different directions appear on the screen to sort of be a loading bar or something.
Good bye.
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests