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
rcmaniac25
Posts: 1,805
Registered: ‎04-28-2009
My Device: Z10 (STL100-4)-10.2.1.3253, Z10 (STL100-3)-10.3.1.997 Dev OS, Z30 (STA100-5)-10.3.1.997 Dev OS, Passport (SQW100-1)-10.3.0.1418, PlayBook (16GB)-2.1.0.1917

Re: scaleInto() problem with trasparent bitmaps

I'd do what aclark said. It says right in the API documentation that the LANCZOS filter "may also introduce some ringing artifacts" which is what I think you are experencing on the star.

 

As for the heart, that's another story, you could try a different filter, changing the bit-depth, etc. Try to isolate it, create a seperete project and do it in that so you can focus on it and it only. If you can't reproduce it then it is something in your app, otherwise it is something with the image and you can try different things to fix it.

---Spends time in #blackberrydev on freenode (IRC)----
Three simple rules:
1. Please use the search bar before making new posts.
2. "Like" posts that you find helpful.
3. If a solution has been found for your post, mark it as solved.
--I code too much. Well, too bad.
Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified

Re: scaleInto() problem with trasparent bitmaps

Yes, it is beyond me too.  I am familiar with the transparent pixels concept, but I didn't even know about adding an alpha channel to a bitmap to get transparent pixels.

 

I did try other filters because the star seems to be a problem with the filter (the heart doesn't though), but it didn't help.  I know it can work on BlackBerry's because I set the bitmaps as the screen background and they scaled properly and the transparent pixels worked.  But using transparent pixels for the screen background does not achieve the desired effect as the user can see the screen below.

 

Thanks again for all the assistance though.  I do not know how I could do this without help from people like you.  I too try to contribute back to the forum that has helped me so much.

Developer
JamesColeman
Posts: 266
Registered: ‎04-24-2009
My Device: Not Specified

Re: scaleInto() problem with trasparent bitmaps

I'm going to see if RIM would like to check this one out. Until then, I figured out a work around for my situation. I just pushed a blank screen the same size as my scaled Bitmap screen, then I pushed my scaled Bitmap screen with set the Bitmap as the screen's back ground. When I set the image as the background, the transparent pixels work, I get no distortion and it scales correctly. The blank screen is required because the transparent pixels show the screen below.
Developer
dnepr
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: scaleInto() problem with trasparent bitmaps

I'm also experiencing artifacting when scaling transperant images.

 

Interesting.   This occurs using all three filters though.

 

If transperancy is not set, the artifacts go away but obvious, alpha channel is also gone.

 

 

Developer
SivaR
Posts: 75
Registered: ‎02-08-2010
My Device: 9000

Re: scaleInto() problem with trasparent bitmaps

Hi All

Even I am trying to get the Transparency pixel when resized. Can you please help me in this context.

 

My Code is

 

_offPicture = new Bitmap( _prefferredWidth,
                         _prefferredHeight);

Bitmap resizeBitmapOff = Bitmap.getBitmapResource(offImage);
resizeBitmapOff.scaleInto(_offPicture,
                          Bitmap.FILTER_BILINEAR,
                          Bitmap.SCALE_STRETCH);

 

After the above code, I am using "_offPicture" inside BitmapField.

 

Can you tell me what and How I need to set Alpha, so that I can see transparent Image

 

 

offPicture
Thanks
Siva
Developer
SivaR
Posts: 75
Registered: ‎02-08-2010
My Device: 9000

Re: scaleInto() problem with trasparent bitmaps

Hi All

After trying few more times, I got the solution and the code is as follows

 

 

public static Bitmap resizedImage(String imageName, int width, int height) {

    Bitmap actualBitmap = Bitmap.getBitmapResource(imageName);
    Bitmap resizedBitmap = new Bitmap(width, height);

    resizedBitmap.createAlpha(Bitmap.ALPHA_BITDEPTH_8BPP);
    int[] stripe=new int[width]; for (int n=width-1;n>=0;n--) stripe[n]=0;
    for (int y=height-1;y>=0;y--) resizedBitmap.setARGB(stripe,0,width,0,y,width,1);

    actualBitmap.scaleInto(resizedBitmap, Bitmap.FILTER_BILINEAR, Bitmap.SCALE_STRETCH);

    return resizedBitmap;
}

 

I have a question:

I think there is little bit performance issues by doing a for loop. Is there any other solution for the above

 

 

Thanks
Siva
Developer
dnepr
Posts: 723
Registered: ‎03-12-2009
My Device: Playbook

Re: scaleInto() problem with trasparent bitmaps

Since you should only do the resizing once and than cache, performance of one loop is not going to be noticeable.

 

You should be good to go.

Contributor
Patchou
Posts: 11
Registered: ‎10-02-2010
My Device: Curve 8900

Re: scaleInto() problem with trasparent bitmaps

For those interested, I just posted some code to fix the edging and other artifacts problems created by scaleInto(). Post: http://supportforums.blackberry.com/t5/Java-Development/Solution-for-properly-resizing-transparent-b...