toggle Cinema 14 Aug 2009

Recortar un pedazo de imagen en AS3 Posted by Insane in Actionscript x.x | No responses

crop-rotation-carta-magic

El siguiente es un tip rápido que  me tomo algo de tiempo concluir, espero que sea de utilidad.

/**
*@Comment regresa el espacio Bitmap delimitado por las dimensiones y cordenadas  proporcionadas
*/

import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.IBitmapDrawable;
import flash.display.BlendMode;
import flash.display.PixelSnapping;
import flash.geom.Rectangle;

public static function crop( $x:Number, $y:Number,$width:Number, $height:Number, $displayObject:IBitmapDrawable = null):Bitmap

{

var cropArea:Rectangle = new Rectangle( 0, 0, $width, $height );

var croppedBitmap:Bitmap = new Bitmap( new BitmapData( $width, $height ), PixelSnapping.ALWAYS, true );

var what:* = (($displayObject!=null) ? $displayObject : Stage);

croppedBitmap.bitmapData.draw(what, new Matrix(1, 0, 0, 1, -$x, -$y) , null, BlendMode.NORMAL, cropArea, true );

return croppedBitmap;

}
  • Share/Bookmark

Tags: , ,

Promote this post

Would you like to add this post to your bookmarks? Come on, do not miss any updates and stay tuned.
Please share with us!

This entry no have comments but you can be first .

Leave a Reply ( Guest )

(*)

(will not be published) (*)