개발/개발 자료

[Android] Bitmap -> Byte[] or Byte[] -> Bitmap 변환

시원한물냉 2013. 9. 12. 11:24

비트맵 -> 바이트배열

Bitmap image; // 변환시킬 비트맵
ByteArrayOutputStream stream = new ByteArrayOutputStream();
image.compress(CompressFormat.JPEG , 100 , stream);
byte[] b = stream.toByteArray();



바이트배열 - > 비트맵

byte[] imgBuf = data; // 변환시킬 바이트 배열 Bitmap image = BitmapFactory.decodeByteArray( imgBuf , 0 , imgBuf.length);