안드로이드 개발 질문/답변
(글 수 45,052)
bitmap 을 2개의 폰사이에 전송하려고 byte로 바꾼후 http 통신으로 DB에 저장해서 받게 만들었습니다.
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG, 100, outStream);
byte[] image = outStream.toByteArray();
String profileImageBase64 = Base64.encodeToString(image, 0);
bitmap->string으로 변환후 (과정 1)
byte[] bytePlainOrg = Base64.decode( profileImageBase64 , 0);
ByteArrayInputStream inStream = new ByteArrayInputStream(bytePlainOrg);
BitmapFactory.Options option = new BitmapFactory.Options();
option.inSampleSize = 2;
Bitmap bm = BitmapFactory.decodeStream(inStream, null, option);
string->에서
bitmap으로 변환 됩니다. (과정 2)
이 코드를 한번에 실행시키면 bitmap을 올바르게 출력하지만
과정 1을 거친후 http 통신을 통해 DB에 저장하고 받은 후에 과정 2를 실행시키면 아무것도 출력하지 않습니다.
로그캣으로 확인해 본 결과 과정 2의 맨마지막 줄에 있는 bm에 null 값이 받아 집니다.
혹시 http 통신중에 데이터가 손실되었는지 확인해보려고 각각 과정의 string 값을 비교해 보았지만 똑같은 값을 가진다는 것도 확인 하였습니다.
해결책이나 혹은 무엇이 문제인지 알려 주시면 정말 감사하겠습니다.




option 값을 넣지 말고 한번 해보세요^^