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
New Developer
vvn_murali
Posts: 61
Registered: ‎06-07-2011
My Device: Playbook
My Carrier: Employee

Unable to get the modified BitmapImage

HI,

 

I am doing a flex project, here I have to apply some filter on an given image and save it to the file system, applying the require filters is fine, but when I am trying to get the modified image baitmapData, getting  only the source image baitmapData, Please any one tell me how to get the modified image data, Here is my code look likes,

 

var filter:BlurFilter = new BlurFilter(10,10,1);

foreground.blendMode='colordodge';

var bitmapData = foreground.bitmapData;

 

<s:BitmapImage id="foreground" x="20" y="10" width="500" height="500"></s:BitmapImage>

 

Thanks in advance..

Please use plain text.
BlackBerry Development Advisor (Retired)
rmasroor
Posts: 172
Registered: ‎06-07-2010
My Device: BlackBerry 8520
My Carrier: Rogers

Re: Unable to get the modified BitmapImage

Hello Murali,

 

 

How are you doing? I hope all is well.

 

Can you reclarify what you are currently doing with BitmapData, what do you hope to accomplish with BitmapData, and what is the current issue.

 

Looking forward to your reply.

 

Sincerely.

Raihan Masroor
BlackBerry Development Advisor
Please use plain text.
New Developer
vvn_murali
Posts: 61
Registered: ‎06-07-2011
My Device: Playbook
My Carrier: Employee

Re: Unable to get the modified BitmapImage

Thanks for your reply,

 

Here is my code exactly

 

[Embed(source="images/britney-spears.jpg")]
			private var MyPic:Class;

protected function viewActivateHandler(event:ViewNavigatorEvent):void
			{
		
				var foregroundImg:Bitmap = new MyPic() as Bitmap;
				var filter:flash.filters.BlurFilter = new flash.filters.BlurFilter(5,5,BitmapFilterQuality.HIGH);
				foreground.source = foregroundImg.bitmapData;
				foreground.filters = new Array(filter);
				//group2.blendMode='colordodge';
			}

protected function clickHandler(event:MouseEvent):void
			{
				test.source = foreground.bitmapData;
			}

<s:Group id="group2" horizontalCenter="0">
				<s:BitmapImage id="foreground" x="20" y="10" width="500" height="500">
				</s:BitmapImage>
			</s:Group>
			<s:Button label="click me" click="clickHandler(event)" />
<s:Group width="30%" height="100%">
			<s:BitmapImage id="test" width="500" height="500">
				
			</s:BitmapImage>
		</s:Group>

 

In the above code after applying the Blur filter to the foreground BitmapImgae, I am trying to get the data from the foreground BitmapImage using bitmapData porperty, but its give only the source of that BitmapImage but not the modified image (blur applied image). So please tell me is there any way to get that modified bitmapdata.

 

Please use plain text.
Developer
shawnblais
Posts: 439
Registered: ‎10-25-2010
My Device: Not Specified

Re: Unable to get the modified BitmapImage

When you use .filters, you're applying the filter to the display object (the Bitmap), not to the bitmapData itself.

 

The way to do this is the applyFilter() API:

foregroundImg.bitmapData.applyFilter(foregroundImg.bitmapData, foregroundImg.bitmapData.rect, new Point(), filter);

http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00000778.html

Please use plain text.
New Developer
vvn_murali
Posts: 61
Registered: ‎06-07-2011
My Device: Playbook
My Carrier: Employee

Re: Unable to get the modified BitmapImage

Yes this is the right solutions for my problem, in other case is I have to set the blendMode of foreground BitmapImage to 'colordodge', In this case how can I get the modified foreground bitmapdata.(I tried to set the blendMode of foregroundImg but it doesn't accepting colordodge property or I am I missing something?)

Please use plain text.
Developer
shawnblais
Posts: 439
Registered: ‎10-25-2010
My Device: Not Specified

Re: Unable to get the modified BitmapImage

If I were doing it, I would keep a cahced 'originalData', and always use that as the source when calling applyFilter, this way you can easily switch between colorDodge, and blur without ever writing over the original bitmap.

 

If you really want to use .filters, then what you would have to do is a draw() call on the displayObject, this will render the object to a bitmapData() and you can use that. 

Please use plain text.
New Developer
vvn_murali
Posts: 61
Registered: ‎06-07-2011
My Device: Playbook
My Carrier: Employee

Re: Unable to get the modified BitmapImage

Could you please post some sample code here.

Please use plain text.
New Developer
vvn_murali
Posts: 61
Registered: ‎06-07-2011
My Device: Playbook
My Carrier: Employee

Re: Unable to get the modified BitmapImage

Hello Shawnblais, please give me some example(code) on what your are saying. I am waiting for your reply.....
Please use plain text.