In many GUI design purposes we need to get bitmap images from existing files in memory card.This method returns bitmap image of the given file name file must be located in path “file:///SDCard/Themes/”
public Bitmap getBitmap(String fileName)
{
Bitmap bkBitmap = null;
try {
FileConnection fconn = (FileConnection)Connector.open("file:///SDCard/Themes/"+fileName );
InputStream input = null;
input = fconn.openInputStream();
int available = 0;
available = input.available();
int fSz = (int)fconn.fileSize();
byte[] data = new byte[fSz];
input.read(data, 0, fSz);
EncodedImage image = EncodedImage.createEncodedImage(data,0,data.length);
bkBitmap = image.getBitmap();
}
catch(Exception e)
{
}
return bkBitmap;
}
Hi Sanjeewa,
ReplyDeleteI was try this code. I get problem with the image. Image is fixed size in my screen, wont to scroll right/left. Image just scroll to up and down.
I'm sorry about my english. Thank'sfor you'r help.
Mugiono