The forums have permanently moved to forum.kirupa.com. This forum will be kept around in read-only mode for archival purposes. To learn how to continue using your existing account on the new forums, check out this thread.


Results 1 to 4 of 4

Thread: Resize a bitmap?

  1. #1

    Resize a bitmap?

    Oh man, this is really getting to me. Ive searched long and hard, and nothing is helping me. Or Im searching wrong. Either way... Im trying to make a simple painting app where you can paint on top of your own images. So I load an image from the server, and make it into a bitmap:

    (1)
    var image:Bitmap= Bitmap(loader.content);
    Then I paint it onto a canvas using the beginBitmapFill method...

    (2)
    paintCanvas.graphics.beginBitmapFill(image.bitmapD ata);
    paintCanvas.graphics.drawRect(0,0,400,300);
    paintCanvas.graphics.endFill();
    However, the image loaded from the server is 640x480, and doesnt all fit into my small 400x300. How can I resize it a bitmap, so just before point 2 above???

    TIA, jamie

  2. #2
    236
    posts
    Artist/Programmer
    You can't resize a BitmapData object.

    You'll need to draw your image to a new BitmapData object (of the size you want), applying a scale transform in the process (if you want to scale it) and display the new BitmapData

    (1)
    var newBMD:BitmapData = new BitmapData(400,300); // or whatever size you want
    var image:Bitmap(loader.content);

    newBMD.draw(image.bitmapData, ...); // use matrix to scale the image during the draw

    (2)

    paintCanvas.graphics.beginBitmapFill(newBMD);
    ...



    Carl

  3. #3
    Excellent! Thank you! Works like a charm.

  4. #4
    236
    posts
    Artist/Programmer
    Your welcome

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012