BIT-101 [2003-2017]

Flash 10 BitmapData.draw fails beyond 4096 pixels?


So Flash 10 allows us to create bitmaps that are larger than the 2880 pixels. Up to 8192 wide or tall (though not both – there’s a maximum pixel count). I’ve covered this in depth in a previous post.

But it seems like there is a bug with the draw method. I can’t seem to draw anything in it beyond 4096 pixels. Here’s an example:

[as][SWF(width=800, height=200, backgroundColor=0xffffff, frameRate=31)]

var bmpd:BitmapData = new BitmapData(8000, 2000, false, 0x00ffff);
var bmp:Bitmap = addChild(new Bitmap(bmpd)) as Bitmap;
bmp.width = 800;
bmp.height = 200;

var s:Sprite = new Sprite();
s.graphics.beginFill(0xff0000);
s.graphics.drawRect(0, 0, 90, 90);
s.graphics.endFill();

for(var i:int = 0; i < 8000; i+= 100) { bmpd.draw(s, new Matrix(1, 0, 0, 1, i, 100)); }[/as] What’s happening here is I’m making a BitmapData that is 8000x2000, adding it to a Bitmap and putting that Bitmap on stage. Then sizing the Bitmap itself down so you can see the whole thing on stage (800x200). Then I’m creating a sprite and drawing a red rectangle in it. And finally, drawing that sprite to the BitmapData repeatedly from 0 to 8000 on the x axis. But, as you can see here, what happens is that the drawing fails about half way across - 4096 pixels: bitmap_error

You can see a similar problem by drawing a 8000 pixel wide rectangle in the sprite and drawing it once to the bitmap. Only the first 4096 pixels will appear on the bitmap.

I’ve searched around and don’t see anyone talking about this. Is this a known error? Any workarounds?

« Previous Post
Next Post »