Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

Reply
Developer
noahnu
Posts: 138
Registered: ‎01-09-2011
My Device: Blackberry Tablet OS
Accepted Solution

Draw Bitmap on Image

[ Edited ]

Hello,

 

how do I draw a bitmap to an image's graphic object?
Here is my code now:
var bmp:BitmapData = new BitmapData(this.width,this.height);
bmp.draw(this);
drawingCanvas.graphics.lineStyle();
drawingCanvas.graphics.beginBitmapFill(bmp);
drawingCanvas.graphics.drawRect(this.x,this.y,this.width,this.height);
drawingCanvas.graphics.endFill();

 

this = Image to be added
drawingCanvas = Main Image
The issue with my code above is that it basically adds the bmp to the entire image and then makes the part (this.width,this.height) visible. In this case the only way for a bitmap to be added succesfully would be for the x and y coordinates of the drawRect to be 0. Otherwise I only see a portion of the image which may be repeated showing half of one image and half of another.
What I want to do is to litteraly place the contents of one Image directly into the graphics object of another image at a specified x and y coordinate.

 

From,
Noah NU
Please use plain text.
Developer
peter9477
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Draw Bitmap on Image

You can't just add the BitmapData to a Bitmap and add that as a child on the object?

 

If for some reason you must draw this into your object's graphics object, then I believe you have to use a trick involving a combination of a translation Matrix and drawRect().


Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!
Please use plain text.
Developer
noahnu
Posts: 138
Registered: ‎01-09-2011
My Device: Blackberry Tablet OS

Re: Draw Bitmap on Image

The reason I can't just add it as a child is because I need to save the final image to a file. If there are multiple children tied to this image I don't believe I can save all of them to a file, can I?

From,
Noah NU
Please use plain text.
Developer
studiochris
Posts: 165
Registered: ‎10-26-2010
My Device: BlackBerry® PlayBook™
My Carrier: .

Re: Draw Bitmap on Image

Saving a parent object as BitmapData should also include its children as displayed.

Please use plain text.
Developer
noahnu
Posts: 138
Registered: ‎01-09-2011
My Device: Blackberry Tablet OS

Re: Draw Bitmap on Image

Thanks

 

However I went with Peters link: translation Matrix and drawRect

From,
Noah NU
Please use plain text.