ScaleBitmap : new version [by Didier Brun]

Let me introduce the new version of ScaleBitmap :

ScaleBitmap new version

I have totally rewritten ScaleBitmap to suit my needs :

  • Better usage of memory : no more creation of BitmapData instance (possibility to swap BitmapData)
  • Outer drawing capability
  • ScaleBitmapSprite
  • The outer drawing & ScaleBitmapSprite allows you to :

  • Easily deal with shadow, glow, overlapping icon effects
  • Use real size & position to align or place your elements
  • Usage 1 : ScaleBitmap

    ScaleBitmap.draw(
    bitmap : BitmapData, // the bitmap source
    graphic:Graphics, // the destination graphic
    width:Number, // width (defined by outer rectangle if not null)
    height:Number, // height (defined by outer rectangle if not null)
    inner : Rectangle, // inner rectangle for scale 9
    outer : Rectangle=null // outer rectangle : visual size reference
    ):void
    

    If outer is not null, ScaleBitmap use a negative offset for drawing (according to outer properties)
    If outer is null, ScaleBitmap works as a classic Scale9 grid drawer

    Usage 2 : ScaleBitmapSprite

    ScaleBitmapSprite(
    bitmap : BitmapData, // the bitmap source
    inner : Rectangle, // inner rectangle for scale 9
    outer : Rectangle=null) // outer rectangle : visual size reference
    
    var s:ScaleBitmapSprite=new ScaleBitmapSprite(mySkin, new Rectangle(20,20,80,20), new Rectangle(15,15,90,30));
    addChild(s);
    s.width=80;
    s.height=40;</a>
    

    ScaleBitmapSprite override public size setter & getter : you can move & resize a ScaleBitmapSprite object without taking care of bitmap outer drawing.

    Simple MyButton class using ScaleBitmapSprite (click the button) :

    A Flash animation should have appeared here, but it seems that your browser has an older version of the Flash Player or it is not installed at all. Please, install the last release of the Flash Player now, then reload this page.


    Sources FCS4 [ require Eaze to compile]

    Download ScaleBitmap & ScaleBitmapSprite :
    Repository : http://gist.github.com/264250

    Some of you prefer gist, so as possible, I will share my new projects via gist.

    Hope this class help & merry Xmas to bytearray readers.

    Comments (5)

    1. fenixkim wrote::

      Long waiting for these improvements, many congratulations on this great and usable class

      Monday, December 28, 2009 at 3:56 pm #
    2. Very nice work!

      Monday, December 28, 2009 at 4:16 pm #
    3. The original class was great and this one is even better. The new outer rectangle is going to be a time saver. Thanks!

      Monday, December 28, 2009 at 4:58 pm #
    4. James Penman wrote::

      Thanks for the excellent utility class. Stuff like this really helps with every scale of web design project’s productivity. You’re the man.

      Monday, December 28, 2009 at 5:06 pm #
    5. Antonin wrote::

      Génial ! Très beau boulot, bravo !

      Saturday, January 9, 2010 at 10:07 am #