More about the comic download tool
I expected to release a downloading tool for Marvel Digital Comics Unlimited at the end of last week but ran into some last-minute troubles.
The comics online at MCDU exist in two different formats: Older issues that appear to have been scanned from paper, and newer issues that appear to have come directly from a digital workflow. The old ones are plain JPG files that are easy enough to use in a third-party application. The new ones however, are JPG files of background art with SWF files containing speech balloons layered on top.
To convert the SWF text layer into an image I’ve been using ByteScout‘s SWF To Image library. It’s a decent, free tool but there have been some hiccups. The text SWF files have an overall movie background colour of white, or #FFFFFF. So if you convert them as-is, you get white speech balloons on top of a white background:
That’s no good, because if you deleted all of the white and put it on top of the background you’d have this:
So as a solution I tried creating my own SWF that would load the JPG and text SWF in layers and then convert all that into a single image. It worked… Sort of. SWF To Image executes and captures an image too quickly for the loadMovie commands in my custom SWF to finish loading Marvel’s SWF and JPG. The only time it worked was when I used an example VBScript with a MsgBox prompt as an interruption, or in my actual program by writing the final image to disk several times in a row. That’s not a hack I’m willing to live with.
I messed around with various ways of loading content in Flash with events that determine whether or not the content has finished loading but in the end I couldn’t reliably render the correct final image. For a different approach I looked into the SWF format itself. This reference to the SetBackgroundColor command being an RGB value set in every movie got me thinking… If I altered the downloaded SWF files to use a different background colour, it could easily be replaced.
By changing this series of bytes “43 02 FF FF FF” in the header of the text SWF to “43 02 FF 00 FF”, I’m left with exactly what I need:
Now that the background isn’t white, purple is deleted instead, leaving this on top of the background:
However this new method has not been done programmatically yet. (Only with a hex editor, some screenshots, and Photoshop.) There won’t be an issue replacing bytes representing the background colour, but going on to cleanly remove that new purple background may require some fine-tuning.
More to come…
Social Media