About

<#TEMPLATE_INCLUDE_NINEPAGE_ABOUTME#>
  • Jan

    12

    AIR / FLEX / AS3 裁切图像

    • 0 Comments
    • Flash Platform
    import flash.display.BitmapData;
    import flash.display.DisplayObject;
    import flash.geom.Matrix;
    import flash.geom.Rectangle;
    //inScale为缩放系数
    function cropBitmapData( inDisplayObject:DisplayObject, inWidth:int, inHeight:int, inX:int, inY:int, inScale:Number = 1):BitmapData {
     if (!inDisplayObject) {
      throw new Error('inDisplayObject 显示对象必须在列表上');
      return null;
     }
     var cropArea:Rectangle = new Rectangle( 0, 0, inWidth * inScale, inHeight * inScale);
     var croppedBitmapData:BitmapData = new BitmapData( inWidth * inScale, inHeight * inScale);
     croppedBitmapData.draw(inDisplayObject, new Matrix(inScale, 0, 0, inScale, -inX, -inY), null, null, cropArea, true );
     return croppedBitmapData;
    }