Quote:
Originally Posted by Dougsg38p You cannot use the Bitmap.getBitmapResource() with a file connection. This method expects the path of a bitmap that is embedded in the COD file.
To load in this fashion, you wil geed to use FileConneciton and InputStream, then use createFromBytes(), or utilize EncodedImage. |
Thank, i will auto respond
I use this code to draw a picture from phone and it work:
PHP Code:
public void paint(Graphics g) {
try {
FileConnection fconn = (FileConnection)Connector.open("file:///store/home/user/pictures/IMG00004-20100306-2130.jpg");
// FileConnection fconn = (FileConnection)Connector.open(path);
System.out.println("Connection establish ");
if (fconn.exists())
{
InputStream input = fconn.openInputStream();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
int j = 0;
while((j=input.read())!=-1)
{
baos.write(j);
}
bytexxx91;xxx93; data = baos.toByteArray();
EncodedImage image = EncodedImage.createEncodedImage(data,0,data.length);
image = sizeImage(image,360,480);
g.drawImage(0,0,300,400,image, 0,0,0);
}
else
{
add(new LabelField("Picture doesn't exist"));
}