How to cut a square in the middle of a bitmap with AS3

Angha110
Angha110 used Ask the Experts™
on
I know how to crop an image using AS3 but what if i want to cut a section on the bitmap. Let say you have a image of a house and you want to select a section on the image and cut it so it shows the image behind it. The ideal way would be a selectable tool that you can change the size and move on top of the house image and once you are done, click a button and that part of bitmap is cut.
Is this doable?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
well, for one, you are going to need to be familiar with MouseEvent.  Second, you will need to store mouseX and mouseY, and translate that to a position within the image/displayObject.  I think that there is an actionscript function for that.  Then, once you have the dimensions of the new selection, create a new bitmap based on the selection, or translate the current image.  I apologize, I'm short on this solution, as there is more to it...

Author

Commented:
Thank you for the information. I am very new to the bitmap classes. Lets say I want to cut 100 pixel square at the middle of the bitmap. (just taking out the MouseEvent)
How would I do it?
I think you  need to use BitmapData.getPixels(x, y, width, height), but that is just off the top of my head. then you can set BitmapData to a new Bitmap object. I"m sorry, I have another project right now and cannot get the code for you, but here is a link to a site that demonstrates some usage of the Bitmap & BitmapData class.
http://www.8bitrocket.com/newsdisplay.aspx?newspage=6765

Author

Commented:
I did read the tutorial, but still can't come up with the right path to do what I need.
Thank you for the tip anyway.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial