vendredi 27 mai 2011
Draw / copyPixels - cropping BitmapData
Par Ivan solart, vendredi 27 mai 2011 à 08:28 :: Flash Action Script 3
var bitmapData_1:BitmapData=new BitmapData(MovieClip(root).width,MovieClip(root).height); // generate bitmapData with root size image.draw(MovieClip(root)); // drawing the BitmapData (root image) var posX:uint = posY:uint = 0; var recWidth:uint = recHeight:uint = 100; var bitmapData_2:BitmapData=new BitmapData(recWidth, recHeight); // generate second BitmapData with the width/height we want bitmapData_2.copyPixels(bitmapData_1, new Rectangle(posX, posY, recWidth, recHeight), new Point(0,0)); // put the image into the second BitmapData and draw from 0,0 top left