Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    BitmapData size problem

    BitmapData has limited size (2880x2880). How to create bitmap larger than that?

  • #2
    New to the CF scene
    Join Date
    Sep 2010
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try this:

    public class VirtualScreenBitmapData
    {
    private const maxWidth:int = 2880;

    private var bitmapArray:Array;

    private var width:int;
    private var height:int;

    public function VirtualScreenBitmapData(width:int, height:int, transparent:Boolean, fillColor:uint)
    {
    bitmapArray = new Array();

    this.width = width;
    this.height = height;

    var count:int = Math.ceil(width/maxWidth);

    for(var i:int=0; i<count; i++)
    bitmapArray.push(new BitmapData(i<(count-1)?maxWidthwidth-(count-1)*maxWidth), height, transparent, fillColor));
    }

    public function get Width():int
    {
    return width;
    }

    public function get Height():int
    {
    return height;
    }

    public function Dispose():void
    {
    for(var i:int=0; i<bitmapArray.length; i++)
    (bitmapArray[i] as BitmapData).dispose();
    }

    public function Draw(source:IBitmapDrawable):void
    {
    for(var i:int=0; i<bitmapArray.length; i++)
    {
    var mx:Matrix = i!=0?new Matrix(1, 0, 0, 1, -i*maxWidth):null;
    (bitmapArray[i] as BitmapData).draw(source, mx);
    }
    }

    public function CopyTo(dest:BitmapData, sourceRect:Rectangle, dx:int):void
    {
    var x1BitmapIndex:int = Math.floor(sourceRect.x/maxWidth);
    var x1:int = sourceRect.x%maxWidth;
    var x2BitmapIndex:int = Math.floor((sourceRect.x+sourceRect.width)/maxWidth);
    var x2:int = (sourceRect.x+sourceRect.width)%maxWidth;
    var left:int;

    var rect1:Rectangle = new Rectangle(x1, 0, x1BitmapIndex==x2BitmapIndex?(x2-x1)maxWidth-x1), height);
    dest.copyPixels(bitmapArray[x1BitmapIndex], rect1, new Point(dx, 0));
    left = dx+rect1.width;
    for(var i:int=x1BitmapIndex+1; i<x2BitmapIndex; i++)
    {
    dest.copyPixels(bitmapArray[i], new Rectangle(0, 0, maxWidth, height), new Point(left, 0));
    left += maxWidth;
    }
    if (x2BitmapIndex!=x1BitmapIndex)
    dest.copyPixels(bitmapArray[x2BitmapIndex], new Rectangle(0, 0, x2, height), new Point(left, 0));
    }
    }

    This class is part of finance ticker package. Visit http://www.ta-guru.com/ticker.php5 to download whole package. There you will see how you can use this class.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •