A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Bitmap Drawing

  1. #1
    Senior Member
    Join Date
    Jun 2001
    Posts
    343

    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);

  2. #2
    Senior Member
    Join Date
    Jun 2001
    Posts
    343
    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);

  3. #3
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    There is also a param for a clipping rectangle that does exactly what you describe:

    PHP Code:
    bmpData.draw(mainImagenullnullnull, new Rectangle(-100, -100100100)); 

  4. #4
    Senior Member
    Join Date
    Jun 2001
    Posts
    343
    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?

  5. #5
    Ө_ө sleepy mod
    Join Date
    Mar 2003
    Location
    Oregon, USA
    Posts
    2,441
    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
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center