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
Posts: 138
Registered: ‎01-09-2011
My Device: Blackberry Tablet OS

Automatically Resize Bitmap When Image is Resized

Hello, I have an Image object and have set its content using setImage(). When I resize the image by doing Image.width = 500 (for example) the actual image object will resize but the content inside of it will remain the same. Calling setImage everytime I resize the image isn't very efficient as it isn't an instant processing calling setImage. So how would I accomplish resizing the image content every time the image is resized?

From,
Noah NU
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Automatically Resize Bitmap When Image is Resized

I haven't used Image myself (just Bitmaps) but do they not support scaleX and scaleY?  That's how I'd expect to scale a bitmap...


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!
Developer
Posts: 138
Registered: ‎01-09-2011
My Device: Blackberry Tablet OS

Re: Automatically Resize Bitmap When Image is Resized

scaleX and scaleY resize the Image but do not resize the BitmapData within it. Is there a way to change the containment of the bitmap data? How would I access the bitmap data in the first place since there is no option like Image.bitmapdata?

From,
Noah NU
Highlighted
Developer
Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Automatically Resize Bitmap When Image is Resized

Depending on what you're trying to accomplish, you may be going about it wrong.  Actually resizing the data repeatedly would be Very Bad.  You'd get all kinds of nasty artifacts building up from the repeated transformation.  Generally you would want to do something like scaling a copy of the original, and only if and when it was time to write out the final modified data (assuming you want to do that) would you actually apply a resize operation to modify the data, once.

 

None of that helps you find out how to get to the BitmapData from an Image, of course... but for that I'd simply recommend you retrieve BitmapData in the first place, and use that to do the setImage().  Keep a copy of it around for later, and you're all set.


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!
Developer
Posts: 138
Registered: ‎01-09-2011
My Device: Blackberry Tablet OS

Re: Automatically Resize Bitmap When Image is Resized

[ Edited ]

I figured out how to get the Bitmap but how would I use scaleX and scaleY to scale the image according to its containers (The actual image object) width & height?

 

Also is there a more efficient method since I will be using this a lot so that the user can resize an image with his/her mouse?

 

EDIT:

 

I have resolved the scale issue by rereading another thread I started.

http://supportforums.blackberry.com/t5/Tablet-OS-SDK-for-Adobe-AIR/Autosize-an-image/m-p/776061/high...

 

My question about the efficiency still stands though.

From,
Noah NU