- Hi,
I'm trying to send a small image (PNG or JPG) from my computer to my blackberry simulator via a socket. The entire image seems to transfer fine, the problem arises when I try to display it, by calling:
Code:EncodedImage.createEncodedImage(data, 0, data.length); // or Bitmap.createBitmapFromBytes(data, 0, -1, 0); // or Bitmap.createBitmapFromPNG(data, 0, -1);
SocketConnection sc = (SocketConnection) Connector.open("socket://<my computer's IP>:5000;deviceside=true");
Thanks,
Sean07-23-09 02:15 PMLike 0 - Yeah, that's the problem. The bytes parameter is not valid, even though... it is. I'm pretty sure it's receiving all the bytes. I even tried putting the same picture into the IDE and loaded it from the program, and that works. So the picture is guaranteed to be in the correct format. Something must be wrong with the socket. Any ideas?
Server:
Code:Socket s = ss.accept(); OutputStream os = s.getOutputStream(); os.write(data, 0, data.length); os.flush();
Code:SocketConnection sc = (SocketConnection) Connector.open("socket://<ip>:5000;deviceside=true"); InputStream is = sc.openInputStream(); byte[] data = new byte[5000]; is.read(data, 0, 5000); Bitmap b = Bitmap.createBitmapFromBytes(data, 0, data.length, 1); add(new BitmapField(b));
07-24-09 08:22 AMLike 0
- Forum
- BlackBerry Developers
- Developers Lounge
Problem with sending image to blackberry
LINK TO POST COPIED TO CLIPBOARD