Create Bitmap image as follows then
Bitmap _bitmap;
_bitmap=getBitmap("file:///SDCard/image.jpg");
int h=_bitmap.getHeight();
int w=_bitmap.getWidth();
Dialog.alert("height"+Integer.toString(h)+"width"+Integer.toString(w));
getBitmap image will be like this
public Bitmap getBitmap(String filepath)
{
Bitmap bkBitmap = null;
try {
FileConnection fconn = (FileConnection)Connector.open(filepath );
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;
}
No comments:
Post a Comment