Sign in to follow this  
Storyyeller

generating sprite sheets

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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. ;)

Share this post


Link to post
Share on other sites
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.


from PIL import Image

def 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 = 0
maxwidth = 0

for i in imglist:
if i.size[0] > maxwidth:
maxwidth = i.size[0]
if i.size[1] > maxheight:
maxheight = i.size[1]

print maxwidth, maxheight



Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this