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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810
Accepted Solution

BackgroundFactory.createBitmapBackground REPEAT_HORIZONTAL not working on os 5.0

Hi,

 

I am setting the background of a VerticalFieldManager using 

BackgroundFactory.createBitmapBackground(bgImg, 0, 0, Background.REPEAT_HORIZONTAL);

Works fine on OS 7.0 (and 6.0) but it doesn't repeat the bitmap on 5.0.

The bitmap is drawn only once.

I wouldn't like to resort to creating an extremely wide resource (to fit both portrait and landsape on different models).

 

Any suggestions?

 

 



"Listen carefully, I shall say this only once"
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: BackgroundFactory.createBitmapBackground REPEAT_HORIZONTAL not working on os 5.0

Override paintBackground for the VFM and paint the repeat yourself?

 

Is this reproducible on the Simulators?

Developer
Posts: 729
Registered: ‎05-04-2011
My Device: 9700

Re: BackgroundFactory.createBitmapBackground REPEAT_HORIZONTAL not working on os 5.0

Hi,

 

Try this:

 

BackgroundFactory.createBitmapBackground(bgImg, Background.POSITION_X_LEFT, Background.POSITION_Y_CENTER, Background.REPEAT_HORIZONTAL);

E.

Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: BackgroundFactory.createBitmapBackground REPEAT_HORIZONTAL not working on os 5.0

Yes. It's reproducible on simulator (tested with 9700@2.13.0.108)


"Listen carefully, I shall say this only once"
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: BackgroundFactory.createBitmapBackground REPEAT_HORIZONTAL not working on os 5.0

@maadani

 

Unfortunately your suggesting didn't work neither.

 

I will now resort to either:

a) manually duplicating the image (luckily it has no alpha channel, cause I could never copy alpha successfully  ) and passing it to background factory or

b) follow Peter's advice about HFM with overridden paintBackground.

 

Thank you both for your input.



"Listen carefully, I shall say this only once"
Developer
Posts: 412
Registered: ‎09-12-2008
My Device: 9000 9810

Re: BackgroundFactory.createBitmapBackground REPEAT_HORIZONTAL not working on os 5.0

[ Edited ]

If nobody has any other idea what might be wrong, let me just chip in with my last and working solution.

 

I extended the Background class and have drawn the repeated image by hand (very similar to the HFM you suggested Peter).

 

Alas, the transparency still doesn't work, but I have already got used to this limitation...

 

public void draw(Graphics graphics, XYRect area)
    {
        int bitmapWidth = bitmap.getWidth();
        int position = 0;
        int repeatX = area.width / bitmapWidth + 1; // one extra for rounding errors
        for (int i = 0; i < repeatX; i++)
        {
            graphics.drawBitmap(area.x + position, area.y, bitmapWidth, area.height, bitmap, 0, 0);
            position += bitmapWidth;
        }
    }

 



"Listen carefully, I shall say this only once"
Highlighted
Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: BackgroundFactory.createBitmapBackground REPEAT_HORIZONTAL not working on os 5.0

[ Edited ]

I have similar code which I use to paint the background of a Button.  Transparency works fine for me. 

 

In fact I use the Raster Operation to replicate the background for me, as follows:

graphics.tileRop(Graphics.ROP_SRC_ALPHA, 0, 0, this.getWidth(), bitmapToDisplay.getHeight(), bitmapToDisplay, 0, 0);

 

Remember if you are scaling a transparent Bitmap, you need to use the code supplied here:

http://supportforums.blackberry.com/t5/Java-Development/Resizing-Transparent-Bitmaps/ta-p/703239

 

In the example above, bitmapToDisplay has been scaled to be the correct height using the code from KB article. So I could have coded this.getHeight() rather than bitmapToDisplay.getHeight().  If it had not been scaled, then I think that I could have coded this.getHeight() and the image would have been tiled correctly. 

Developer
Posts: 18
Registered: ‎08-01-2008
My Device: Blackberry Curve 8900
My Carrier: Bharti Airtel India

Re: BackgroundFactory.createBitmapBackground REPEAT_HORIZONTAL not working on os 5.0

Thanks Peter, your post helped me once again.

 

I used following code to create my background.

 

protected void paintBackground(Graphics graphics) {
	Bitmap bitmapToDisplay = new Bitmap(CommonUtilities.topNavBarBackgroundStrip.getWidth(), this.getHeight());
	CommonUtilities.topNavBarBackgroundStrip.scaleInto(bitmapToDisplay, Bitmap.FILTER_BILINEAR);
	graphics.tileRop(Graphics.ROP_SRC_ALPHA, 0, 0, this.getWidth(), bitmapToDisplay.getHeight(), bitmapToDisplay, 0, 0);
}

 

 

Do what you love.. Love what you do.. Smiley Very Happy