Client
unknown
kotlin
2 years ago
745 B
4
Indexable
private fun sendAvatar(imgView : ShapeableImageView, socket: Socket){ // Convert Image from picPreview to bytes val bmpDrawable : BitmapDrawable = imgView.drawable as BitmapDrawable val bmp : Bitmap = bmpDrawable.bitmap val bos = ByteArrayOutputStream() bmp.compress(Bitmap.CompressFormat.JPEG, 100, bos) val byteArray = bos.toByteArray() // Get output stream from socket val out = socket.getOutputStream() val dos = DataOutputStream(out) // Write the data trough the socket dos.writeInt(byteArray.size) dos.write(byteArray, 0, byteArray.size) Log.i("DEBUG", "Sent: " + byteArray.size.toString() + " bytes to server.") }
Editor is loading...