BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 03-07-2010, 04:12 PM   #1 (permalink)
New Member
 
Join Date: Mar 2010
Model: 9000
PIN: N/A
Carrier: STUDENT
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Put picture in background

Please Login to Remove!

Hello

I am sorry for my english, i am french

I need help for my application. I want to put a picture in background of my application. The picture is taken with camera. But it don't work and i can't understand why.

Help me please :'(

My code :
PHP Code:
  private VerticalFieldManager _manager;

   
_manager = (VerticalFieldManager)getMainManager();
                
Background bg BackgroundFactory.createBitmapBackground(Bitmap.getBitmapResource("file:///store/home/user/pictures/IMG00004-20100307-1112.jpg"));
                
_manager.setBackground(bg); 
The file "IMG00004-20100307-1112" exists but i can't display it. Why?

tHank
Offline  
Old 03-07-2010, 06:59 PM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Mar 2008
Location: Austin, TX
Model: 9700
PIN: N/A
Carrier: T-Mobile
Posts: 1,644
Post Thanks: 0
Thanked 34 Times in 33 Posts
Default

You cannot use the Bitmap.getBitmapResource() with a file connection. This method expects the path of a bitmap that is embedded in the COD file.

To load in this fashion, you wil geed to use FileConneciton and InputStream, then use createFromBytes(), or utilize EncodedImage.
Offline  
Old 03-09-2010, 06:41 PM   #3 (permalink)
New Member
 
Join Date: Mar 2010
Model: 9000
PIN: N/A
Carrier: STUDENT
Posts: 7
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by Dougsg38p View Post
You cannot use the Bitmap.getBitmapResource() with a file connection. This method expects the path of a bitmap that is embedded in the COD file.

To load in this fashion, you wil geed to use FileConneciton and InputStream, then use createFromBytes(), or utilize EncodedImage.

Thank, i will auto respond

I use this code to draw a picture from phone and it work:

PHP Code:
 public void paint(Graphics g) {
        try {
            
FileConnection fconn = (FileConnection)Connector.open("file:///store/home/user/pictures/IMG00004-20100306-2130.jpg");
          
//  FileConnection fconn = (FileConnection)Connector.open(path);
            
System.out.println("Connection establish ");
            if (
fconn.exists())
            {
                
InputStream input fconn.openInputStream();
           
                
ByteArrayOutputStream baos = new ByteArrayOutputStream();
                
int j 0;
                while((
j=input.read())!=-1)
                {
                    
baos.write(j);
                }
                
bytexxx91;xxx93; data baos.toByteArray();
                               
                
EncodedImage image EncodedImage.createEncodedImage(data,0,data.length);
                
image sizeImage(image,360,480);
                
g.drawImage(0,0,300,400,image0,0,0);
              
            }
            else
            {
                
add(new LabelField("Picture  doesn't exist"));
            } 
Offline  




Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.