List of all Iphone and Blackberry Development codes in a one click Iphone,objective C,xcode,blackberry Development,iOS Development

Friday, April 20, 2012

Read Image from SD Card in Blackberry


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;
}



        

No comments:

Post a Comment