About 18 months ago, I’d been looking for a decent way to circumvent AS3’s annoying BitmapData pixel size limit to easily produce print resolution generative stuff. According to livedocs:
In AIR 1.5 and Flash Player 10, the maximum size for a BitmapData object is 8,191 pixels in width or height, and the total number of pixels cannot exceed 16,777,215 pixels. (So, if a BitmapData object is 8,191 pixels wide, it can only be 2,048 pixels high.)
Keith Peters had the same problem, but there in the comments was a mention of this fantastic hack by Martin Rädlinger at formatlos. BitmapUnlimited does some clever hack thing to do with a GIF that somehow tricks the player to make bigger bitmaps. Works great too.
So in order to make print res bitmaps even easier, I’ve wrapped it in PrintCanvas, a simple little class of my own. Here’s how to use it:
1 2 3 4 5 6 7 8 9 10 11 12
| import tv .palmerama .display .PrintCanvas ;
import tv .palmerama .utils .CustomEvent ;
var printCanvas :PrintCanvas = new PrintCanvas ();
printCanvas .addEventListener("PrintCanvas ready", onPrintCanvasReady );
printCanvas .createPaperType ("A2", 300, "landscape", 0xFFFF00 );
function onPrintCanvasReady (e :CustomEvent ):void
{
addChild(new Bitmap(e .params .bmd ));
printCanvas .saveImage ("PNG", "PNG_test_image");
} |
So that creates an A2, 300dpi, yellow landscape canvas, adds it to the stage in a bitmap once it’s ready and saves it as a PNG. You can have a JPG too with quality setting, plus saveImage() returns its FileReference object in case you want to track progress etc. It can take a while.
Basically, you can have any size you want at any dpi. But beware memory issues! This eats it fast, so the A2 at 300dpi in this example could easily be a killer. That said, currently supported sizes from what I could find on Wikipedia are:
A0, A1, A2, A3, A4, A5, A6, A7, A8, Letter, Legal, Tabloid.
I couldn’t seem to find out much about standard American sizes beyond Letter and Legal (oddly, on the internet). Any help much appreciated.
Grab the zip here.
One big drawback of BitmapDataUnlimited is that it can’t handle filters beyond the usual BMD size. EDIT: See Martin’s comment below. That saves me some work! I’m only really bothered as the look of the screen res images I was playing with a long time back played heavily on the use of glows. Maybe now I can get on with making pretty things again, this time big enough to go on the wall.
January 18th, 2010 by Ad.
It's all about the experiments / r 'n' d, flash | 7 Comments »