1 public byte[] getBitmapByte(Bitmap bitmap){ 2 ByteArrayOutputStream out = new ByteArrayOutputStream(); 3 bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); 4 try { 5 out.flush(); 6 out.close(); 7 } catch (IOException e) { 8 e.printStackTrace(); 9 } 10 return out.toByteArray(); 11 } 12 13 14 public Bitmap getBitmapFromByte(byte[] temp){ 15 if(temp != null){ 16 Bitmap bitmap = BitmapFactory.decodeByteArray(temp, 0, temp.length); 17 return bitmap; 18 }else{ 19 return null; 20 } 21 }