Sprite masking with alpha channels in GraphicsGale (edit: added Python + Pillow script)

Edit: I made a quick-and-dirty Python 3 / Pillow script for applying color key-style alpha channel masks, it can be grabbed here.

I’ve been messing around with Kivy lately, and it seems that there is not a direct method of doing color key transparency in Kivy + OpenGL. No problem: alpha transparency is much more powerful and can be used for my archaic purposes.

blog-transparency

I haven’t worked much with alpha channels in the art package that I use, GraphicsGale. The best solution is probably to loop through the pixels of the texture upon loading or refreshing it in your program, and apply alpha if the color key RGB is detected. In any case, here is how to apply an alpha channel in a color key stencil fashion to 24bpp Full Color PNGs in GraphicsGale:

  • Choose the color picker tool (blue square with a yellow oval) and click on an empty / transparent space in your sprite sheet.

sprite-alpha2

  • Choose View -> Make Alpha Channel…
  • Create From: Current Selection
  • Source: (should be the current file — double check)
  • Check Invert Selection and click OK.
  • When you save the file, use Save As… and ensure that “With Alpha Channel” is checked.

You should now have a stencil alpha layer which you can toggle in GraphicsGale with the “a” button on the current layer. If you’ve tweaked art and need to remake the alpha layer, goto Image -> Delete Alpha Channel and then repeat the steps above.

 

Links

  • Alpha channel notes from an artist working with GraphicsGale and Adventure Game Studio. His example images have expired, unfortunately, but there is some interesting info about drawing in Opacity Mode.

 

(e 23/Oct/2018: Just a quick addendum to note that the GraphicsGale Alpha channel dialog box doesn’t seem to work properly when running under Wine (3.17). In this case, Pillow can be used to generate a sprite mask on the alpha channel.)

(e 3/Jul/2019: So, I’m on wine-4.11 now, and still using GraphicsGale (albeit for a LÖVE game instead of a Kivy game). The alpha mask still doesn’t seem to save, but setting transparency on the frame, and saving as PNG, seems to save a proper color key alpha layer. I can’t remember if this worked at the time — maybe I misunderstood something?

1 Comment

Leave a Comment