Hello,
I'm transferring an image, type is .png, between two phones( DroidX
and Droid) using the SPP/RFCOMM.  When the receiver phone(DroidX) get
the data, it saved the file into the sd.  When I open the image at the
specified sd location, I can see that the image is corrupted.  My code
is base on the "BluetoothChat".  I've been working on this problem for
three days and I'm out of ideas.  Any help is greatly appreciated.
Thank you in advance.

"Droid: Transfer"
Bitmap bm = BitmapFactory.decodeResource(Server.this.getResources(),
R.drawable.icon);
ByteArrayOutputStream os = new ByteArrayOutputStream();
bm.compress(CompressFormat.PNG, 0, os);
byte[] bi = os.toByteArray();
...
out_stream.write(bi);


"DroidX: Receiver"
...
in_stream.read(buffer);
String path = "/sdcard/Bpix/";
 boolean exists = (new File(path)).exists();
 if(!exists)
      new File(path).mkdir();

 FileOutputStream save;
 try{
         save = new FileOutputStream(path+"img.png");
         save.write(buffer);
         save.flush();
         save.close();
}catch(Exception e){}

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to