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. New to the forum? Please visit the ‘Getting Started’ link below.
inside custom component

Java Development

Reply
Developer
kanaksony
Posts: 531
Registered: ‎04-11-2009
Accepted Solution

Bitmap is not displayed

Hi,

 

I am using following code, there is no exception and err throw, label is displayed on the screen but Bitmap is not visible... Am i missing something...? Plz. help

 

 private class AboutScreen extends MainScreen
          {
              
                private Bitmap backgroundBitmap;
                private Bitmap fieldBitmap;
 
                public AboutScreen()
                {
                   
                    this.setTitle("About App");
                    backgroundBitmap = Bitmap.getBitmapResource("logo.png");
                    System.out.println("Width = "+backgroundBitmap.getWidth()+ "\nheight = "+backgroundBitmap.getHeight());
                    vfm = new VerticalFieldManager(VerticalFieldManager.NO_HORIZONTAL_SCROLL | VerticalFieldManager.NO_VERTICAL_SCROLL);
                    hfm_1 = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH)
                    {
                        public void paint(Graphics graphics)
                        {
                            graphics.drawBitmap(0, 0, backgroundBitmap.getWidth(), backgroundBitmap.getHeight(), backgroundBitmap, 0, 0);
                            super.paint(graphics);
                        }           
                    };
                   
                    hfm_2 = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH);
                   
                    s = "This is a label, I want it at the bottom of this Screen";
                    style =  LabelField.USE_ALL_WIDTH | LabelField.FIELD_BOTTOM;
                   
                    lbl_hdr =  new LabelField(s,style)
                    {
                            protected void layout( int maxWidth, int maxHeight )
                            {
                                    int displayWidth = 500; // As reference
                                    int displayHeight = 120; // as reference
                                    super.layout( displayWidth, displayHeight);
                                    setExtent( displayWidth, displayHeight );
                            }                       
                     };
                    hfm_2.add(lbl_hdr);
                    vfm.add(hfm_1);
                    vfm.add(hfm_2);
                    add(vfm);
                }
               
               protected boolean onSavePrompt()
               {
                    return true;
               }
 
         
          } 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Please use plain text.
Developer
peter_strange
Posts: 17,958
Registered: ‎07-14-2008

Re: Bitmap is not displayed

Your HorizontalFieldManager hfm_1  has no Fields in it, so has no need for any screen space, so no need to draw the background image. 

 

I suggest that you use the paint menthod you have for the hfm_1 in the AboutScreen, i.e. overrride the AboutScreen paint method and don't use hfm_1 at all.

Please use plain text.
Developer
kanaksony
Posts: 531
Registered: ‎04-11-2009

Re: Bitmap is not displayed

Hi Peter,

 

Thnx for the response..

 

Well, I would try as you suggestedto override the AboutScreen paint method and not using hfm_1 at all. But, I have gone thru KB article

           

                 http://www.blackberry.com/knowledgecenterpublic/livelink.exe/fetch/2000/348583/800332/800505/800608/...

 

And, in the same manner I am trying to create a background image for my application... Is somethng wrong in using it..?

 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Please use plain text.
Developer
Mudassir
Posts: 209
Registered: ‎11-08-2008

Re: Bitmap is not displayed

 

Try to do like this,

 

 HorizontalFieldManager hfm_1 = new HorizontalFieldManager(HorizontalFieldManager.USE_ALL_WIDTH)
                    {

                        int width = 50;
                        int height = 50;


                        protected void sublayout(int width, int height)
                        {

                            width = this.width;

                            height = this.height;
                            super.setExtent(width,height);
                                               
                        }


                        public void paint(Graphics graphics)
                        {
                            graphics.drawBitmap(0, 0, backgroundBitmap.getWidth(), backgroundBitmap.getHeight(), backgroundBitmap, 0, 0);
                            super.paint(graphics);
                        }          
                    };

Thanks and Regards
Please use plain text.
Developer
kanaksony
Posts: 531
Registered: ‎04-11-2009

Re: Bitmap is not displayed

Thnx Mudassir, it worked...

 

Regards,
Kanak Sony
------------------------------------------------------------------------------------------
http://dodevelopnshare.wordpress.com/ | http://www.linkedin.com/profile/view?id=188131481&trk=tab_pro
Please use plain text.