-
Bitmap Drawing
I want to use the bitmap features of actionscript to take a take a 'photo' of an image. Actually, just a portion of the image. Right now I can control the width and height of the bitmap, but I can only draw it from the upper left corner (0,0) of the original image. I want the bitmap to be a different part of the image. The only way I can think of doing it at this point, is to draw the entire image and use masking, but there must be a better way.
Does anyone know of a way to control where the drawing starts (instead of starting at 0,0)? Below is a part of the code I'm using.
Code:
var bmpData:BitmapData = new BitmapData(100,100,false,0x000000);
bmpData.draw(mainImage);
var myBitmap:Bitmap = new Bitmap(bmpData);
pieceContainer.addChild(myBitmap);
-
I somewhat figured it out. For anyone who cares, I had to add a matrix to bitmap drawing. Something like
var thisMatrix:Matrix = new Matrix(1,0,0,1,-100,-100);
var bmpData:BitmapData = new BitmapData(100,100,false,0x000000);
bmpData.draw(mainImage,thisMatrix);
var myBitmap:Bitmap = new Bitmap(bmpData);
pieceContainer.addChild(myBitmap);
-
There is also a param for a clipping rectangle that does exactly what you describe:
PHP Code:
bmpData.draw(mainImage, null, null, null, new Rectangle(-100, -100, 100, 100));
-
Thanks neznein9. I'm going to stick with the matrix technique because it seems to work better for me.
Is there a way to draw in a shape other than a rectangle? Like a circle?
-
nope - that would have to be masked after the fact.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|