generating sprite sheets
If you have a given bitmap, is there any easy way to generate a color keyed spritesheet consisting of rotations of that image?
Previously, I've been doing it all manually in GIMP, but it takes forever, even for only a handful of frames. Getting rid of the anti aliased edges and lining them up is especially time consuming.
Is there some way to make a GIMP plugin to do it for me? Do I have to learn Perl?
Personally I'd do this with a Python script, using the PIL library (specifically the Image module is very useful). Both are easy to learn.
As for color-keys, why aren't you using alpha-transparency instead? Looks better, and apparently it'll save you some work too. ;)
As for color-keys, why aren't you using alpha-transparency instead? Looks better, and apparently it'll save you some work too. ;)
I'm having trouble figuring out Python.
I figured out how to rotate the image, but now I can't figure out how to translate and paste the frames into one big image. I didn't see anything in the PIL that looked like it would do what I want.
I figured out how to rotate the image, but now I can't figure out how to translate and paste the frames into one big image. I didn't see anything in the PIL that looked like it would do what I want.
from PIL import Imagedef goodrotate(img, theta): """Rotate, expand and crop image""" img2 = img.rotate(theta,Image.BICUBIC,1) return img2.crop(img2.getbbox())loadedimage = Image.open("test.bmp")imglist = []for i in range(0,360/15): imglist.append(goodrotate(loadedimage, i * 15))maxheight = 0maxwidth = 0for i in imglist: if i.size[0] > maxwidth: maxwidth = i.size[0] if i.size[1] > maxheight: maxheight = i.size[1]print maxwidth, maxheight
To paste all the separate images into a single sprite sheet, you can use the montage tool in ImageMagick.
Ok, I got everything working, except that it can't seem to handle transparency. The transparency gets converted to white before rotating for some reason.
Also, there's no antialiasing on the edges.
Also, there's no antialiasing on the edges.
I noticed in your other thread that you're testing with .bmp files. These don't contain an alpha channel, so the PIL Image that you're loading them into will not contain an alpha channel either. Either explicitly create an alpha channel or use a file format that contains an alpha channel, such as .png.
Quote:Original post by Storyyeller
Ok, I got everything working, except that it can't seem to handle transparency. The transparency gets converted to white before rotating for some reason.
Also, there's no antialiasing on the edges.
Ensure all your pixel formats are RGBA, not RGB: white is most likely a random default colour that was hidden until you remove the alpha channel.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement