ListField with image In Blackberry JDE

Posted by Karthick on Stack Overflow See other posts from Stack Overflow or by Karthick
Published on 2010-04-28T10:58:30Z Indexed on 2010/04/28 11:03 UTC
Read the original article Hit count: 569

Filed under:
|

I use the following code to retrieve image from the phone or SDCard and I use that image in to my ListField. It gives the output but it takes very Long time to produce the screen. How to solve this problem ?? Can any one help me?? Thanks in advance!!!

String text = fileholder.getFileName(); try{ String path="file:///"+fileholder.getPath()+text; //path=”file:///SDCard/BlackBerry/pictures/image.bmp”

InputStream inputStream = null; //Get File Connection FileConnection fileConnection = (FileConnection) Connector.open(path);

inputStream = fileConnection.openInputStream();

ByteArrayOutputStream baos = new ByteArrayOutputStream(); int j = 0; while((j=inputStream.read()) != -1) { baos.write(j); } byte data[] = baos.toByteArray();
inputStream.close(); fileConnection.close();

//Encode and Resize image EncodedImage eImage = EncodedImage.createEncodedImage(data,0,data.length); int scaleFactorX = Fixed32.div(Fixed32.toFP(eImage.getWidth()), Fixed32.toFP(180)); int scaleFactorY = Fixed32.div(Fixed32.toFP(eImage.getHeight()), Fixed32.toFP(180)); eImage=eImage.scaleImage32(scaleFactorX, scaleFactorY); Bitmap bitmapImage = eImage.getBitmap();
graphics.drawBitmap(0, y+1, 40, 40,bitmapImage, 0, 0); graphics.drawText(text, 25, y,0,width); } catch(Exception e){}

© Stack Overflow or respective owner

Related posts about blackberry

Related posts about jde