Blackberry BitmapField from SD card

I want to show a image from the SD card in a BitmapField. How to do that? Can anyone give me some sample code for that?

Answers


This may be Help full.

public Bitmap getImage(){
    Bitmap bitmapImage=null;
    try{
        InputStream input;
        FileConnection fconn = (FileConnection) Connector.open("file:///store/home/user/dirname/imgname.png", Connector.READ_WRITE);
        input = fconn.openInputStream();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        int j = 0;
        while((j=input.read()) != -1) {
             baos.write(j);
        }
        byte[] byteArray = baos.toByteArray();

        bitmapImage = Bitmap.createBitmapFromBytes(byteArray,0,byteArray.length,1);


    }catch(Exception ioe){
        System.out.println(ioe);
    }
    return bitmapImage;
}

Enjoy..


Need Your Help

Update class X created by class A from class B. Encapsulation issue

c# design-patterns encapsulation

Previous question (easier): Update class from another class, encapsulation issue

Does the Java VM move objects in memory, and if so - how?

java memory-management garbage-collection jvm

Does the Java virtual machine ever move objects in memory, and if so, how does it handle updating references to the moved object?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.