Thursday, June 6, 2013

Flash to Flipbook

In my animation course, two programs we use to create and compile our animations are Adobe's Flash (http://www.adobe.com/products/flash.html) and Digicel's Flipbook (http://www.digicelinc.com/flipbook.htm).

Today, one of my classmates ran into troubles bringing in her Flash-exported animation into Flipbook. This post is my solution to that problem.

The issue between the two programs is file types. Flipbook will only accept 32 bits-per-channel TGAs as colored overlays and Flash won't export them. My solution uses Photoshop's batch processing to convert an exported PNG sequence to a TGA sequence with an alpha channel.

The first step will be exporting from Flash. You want to "Export movie..." from the File menu and choose to export a series of PNGs (with transparency/alpha channel).






Now, because Flipbook will only accept TGAs, we need to convert the PNGs. I've created a Photoshop action that'll do just that (Photoshop CS3 action, should work with newer versions).

Once you've downloaded the action, it needs to be loaded in Photoshop. To do that, you have to first open the Actions pallet (it can be found under Window -> Actions or Alt+F9 on a PC). When it's open, click the pallet options button in the top-right corner of the pallet and choose "Load Actions". Navigate to the downloaded actions file and hit open. This will add a new actions folder named "Flash to Flipbook" with an action named "PNG to TGA".


Now that the PNG sequence is exported from Flash and the Photoshop action is loaded, we can use Photoshop's batch functions to quickly convert the PNGs to TGAs. So go up to File -> Automate -> Batch.


From here, you'll be presented the batch functions window. Compare your settings with the picture below and make sure to choose your source folder and output folder. Ideally you should have all of your PNGs in one folder and have another folder that will only have your TGAs once Photoshop is done.


When everything looks OK, hit OK and let Photoshop do its thing. Depending on your computer and the number of frames you're converting, it could take a while but when it's done you should have a folder full of TGAs ready for import into Flipbook as colored overlays!

...Now for those who care about what is happening, the process behind the action is quite simple.

Flash exports a PNG with a pre-multiplied alpha channel meaning the transparency is "baked" into the image. We extract this baked in information by selecting the pixels of the PNG based on each pixel's transparency (CTRL-clicking a layer will do this, or go to Layer -> Select Pixels). From that selection, we make a new channel, call it Alpha 1 (its default name), and fill the selection with white. This gives us a white blob that is the shape of the object we want to see (white is visible, black is invisible, and the shades of gray are varying degrees of opacity).

Now that we have a separate alpha channel that Flipbook will read, we need to make the image a straight-alpha image, meaning we get rid of that "baked in" alpha data. We do this by duplicating the layer a bunch of times (15 in the case of this action), effectively making the semi-transparent pixels (anti-aliased edges) opaque. Before we merge the image back down into a single, flattened layer, we add a new layer to the bottom and fill it black.

I chose black because if there's any fringing after the process (which there shouldn't be, but just in case...) black will be more appealing and less obvious against a darker background (which I imagine will be the scenario more often than not). In the off-chance that you have a really light BG and you notice fringing, you'll have to modify the action slightly to fill that layer with a lighter color, instead of black.

Once the layer is in place, we collapse the stack, leaving one layer. Flipbook will read only the color data from the layer and then turn to the alpha channel for the transparency.

No comments:

Post a Comment