Displaying Sample/User Pictures in Application
Greetings,
I am trying to load a picture from either the preloaded sample picture folder or the user picture folder and display it within my application running on OS4.2.x. I am able to extract the URI through a FileConnection and searching at "file:///store/samples/pictures/" and "file:///store/home/user/pictures". However, I am unable to find a way to display the picture. Once I have obtained the file path, is there a way to convert it to a Bitmap or Image for displaying? Any alternative methods? Thank you, Californium |
Bitmap myBitmap = Bitmap.getBitmapResource("ProjRoot/Path");
? |
That seems to give an error:
FRIDG: could not find file:///store/samples/pictures/BBTiles-Orange.png |
Hi ,
file:///store/samples/pictures/ is used to read files that are stored in SDCard or device memory.. Bitmap.getBitmapResource("ProjRoot/Path"); this is used to read a file from the jar. To use this code you need to package the image with in the jar. To display image from the internal memory read the file as bytes and then create byte[] data; EncodedImage.createEncodedImage(data,0,data.length ); Then use can draw the encoded image to a bitmapField or you can create a bitmap from the encoded image. |
Thank you for the information. I will try that out!
Regards, Californium Note: If anyone is curious, here's the code to display the image. Code:
/* |
Is there any version 4.0 alternative code for the above because package
Code:
javax.microedition.io.file.* |
is there any method to display a txt file(text.txt) once u have obtained the file path..
would appreciate for response thanks in advance |
I have Pearl 8100 with OS 4.2.1.109 and the code wont run. It returns Error. do you know why?
|
It seems that the access to the "embedded" image files is completely disallowed...
I had the same problem when I needed an image file for testing the code and was too lazy to copy my own to the device. However the code worked with "normal" images but not with those provided with the device |
Is their is a way to get the h t t p:// instead a file:// I need help . Please reply
|
Hum I try this way but my program throw an error when :
Bitmap b = image.getBitmap(); I know that the path is correct and my byteArray too because I'm successful to send it to a web service. What's wrong?? I use the code given excatly |
Here there is my code
Code:
FileConnection fconn = (FileConnection)Connector.open(cheminPhoto1); I know that my byteArray is correct because I send it to a web service and this last recover the correct picture |
No one can tell me what's wrong???
|
not sure if it applies but at least pictures stored with a contact are encoded in base64.
Code:
byte[] photoEncoded = blackberryContact.getBinary(BlackBerryContact.PHOTO, 0); |
But it's not a picture stored with a contact.
The picture comes from the camera. |
Hum I found a solution.
the problem seems to come from byteArray = new byte[available]; input.read(byteArray, 0, available); I don't know what but it doesn't wrok my byte Array is allways null. So I do this : ByteArrayOutputStream baos = new ByteArrayOutputStream(); int j = 0; while((j=input.read())!=-1) { baos.write(j); } byteArray = baos.toByteArray(); I know that is not a very fast an elegant operation but it works |
All times are GMT -5. The time now is 04:42 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.