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

Java Development

Reply
Developer
Posts: 19
Registered: ‎07-26-2011
My Device: Storm 2 9550
My Carrier: GCI
Accepted Solution

How can I re size a bitmap while keeping my png's original transparency?

[ Edited ]

Greetings and salutations fellow developers,  some quick specifics, I use the blackberry JDE 5.0 and Eclipse.  I'm programming for multiple phones Storm2 and all Torch models.  The display area differs between a few of the phones from 480x360 to 800x480.

 

I have created a method for resizing images based on the aspect ratio here.

public static Bitmap AspectRatio(Bitmap bm)
	  {
		int widthRatio = (int)(360 / bm.getWidth());
		int width = (int)(Utility.SCREEN_WIDTH / widthRatio);
		int heightRatio = (int)(480 / bm.getHeight());
		int height = (int)(Utility.SCREEN_HEIGHT / heightRatio);
		Bitmap temp = new Bitmap(width, height);
		bm.scaleInto(temp, Bitmap.FILTER_BILINEAR);
		return temp;  
	  }

 

This method works great until I try it with my transparent Bitmaps.

 

The transparent part of my bitmaps are black and im not sure how to keep them trasparent.

Example below.

 

Before

X.png                    After

                    X2.png

 

 

How would I keep my opaqueness after stretching?

 

Thanks in advance.

 

 

Developer
Posts: 19,631
Registered: ‎07-14-2008
My Device: Not Specified

Re: How can I re size a bitmap while keeping my png's original transparency?

Developer
Posts: 19
Registered: ‎07-26-2011
My Device: Storm 2 9550
My Carrier: GCI

Re: How can I re size a bitmap while keeping my png's original transparency?

[ Edited ]

 I did see that post I always try to make my own methods but this one is a bit above my head.  Thanks again Peter Smiley Happy -Andrew Mason