Everybody! This is important. In a few days, these forums will be moving over to using the totally sweet Discourse platform. To ensure this migration happens smoothly with no loss of content, these forums are currently in a read-only mode. I do apologize for the inconvenience.

There is never a good time to turn the forums off for an extended period of time, but I promise the new forums will be a billion times better. I'm pretty sure of it.

See you all on the other side in a few days, and if you have any (non-technical) questions, please e-mail me at kirupa@kirupa.com. For technical questions, try to find a tutorial that corresponds to what you are looking for and post in the comments section of that page.


Results 1 to 3 of 3

Thread: copying masked bitmap onto another bitmap

  1. #1

    copying masked bitmap onto another bitmap

    I'm having a bit of a problem copying the masked only pixels from one bitmap onto another. Basically I'm masking bitmap A with bitmap B, which is working fine, but I'm unsure how to copy just the masked pixels onto Bitmap C which is the only one I want to keep.

    //all this works fine
    var _texture:Bitmap = new Bitmap(new Dirt_Bitmap);      
    var _mask:Bitmap = new Bitmap(new Mask_Bitmap);     
    var _planter:Bitmap = new Bitmap(new Planter_Bitmap);
    _texture.cacheAsBitmap = _mask.cacheAsBitmap = true;
    _texture.mask = _mask;
    //This is where things get weird :[
    var newBitmap:Bitmap = new Bitmap(new BitmapData(50, 50, true));
    newBitmap.bitmapData.copyPixels(_texture.bitmapData, _texture.bitmapData.rect, new Point());
    _planter.bitmapData.copyPixels(_newBitmap.bitmapData, _newBitmap.bitmapData.rect, new Point());
    how would I go about just copying or drawing or maybe merg() just the masked texture so its copied over the planter graphic where the dirt should be? Any and all help will be greatly appreciated! :]

  2. #2
    Have you tried using BitmapData#draw instead of copyPixels?

  3. #3
    yes - the result is whatever I masked is gone so it simply draws all of the texture onto my final bitmap instead of simply the masked pixels. :/

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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


Copyright 1999 - 2012