/**
現(xiàn)在要實(shí)現(xiàn)的功能是:app端從圖庫中選擇一張圖片放到ImageView上,然后發(fā)送到服務(wù)端,放到指定文件夾下.
*/
byte?[]?mIconGetBytes()//這是寫的一個(gè)返回圖片的字節(jié)數(shù)組的方法
{
????Bitmap?bm?=((BitmapDrawable)?mIcon.getDrawable()).getBitmap();//mIcon就是一個(gè)ImageView
????ByteArrayOutputStream?baos?=?new?ByteArrayOutputStream();
????bm.compress(Bitmap.CompressFormat.PNG,?100,?baos);
????return?baos.toByteArray();
}
/**
傳輸?shù)臅r(shí)候執(zhí)行的代碼
*/
DataOutputStream?dos=new?DataOutputStream(socket.getOutputStream());
byte?[]?tx=mIconGetBytes();
dos.write(tx);
dos.flush();
/**
服務(wù)端接收的代碼
*/
byte[]?bytes=new?byte[1000*1024];
FileOutputStream?out?=?new?FileOutputStream("d:\\mIcon\\"+name+".bmp");????
in.read(bytes);
out.write(bytes);
out.flush();
out.close();然后有的圖片可以傳過來,但是有的圖片只穿了一部分就像這樣還請(qǐng)各路大神幫幫忙啊┭┮﹏┭┮
添加回答
舉報(bào)
0/150
提交
取消