2012-07-21 2 views

답변

1

getResources() 방법을 사용하여 드로어 블을 얻습니다. BitmapDrawable에

Drawable drawable= getResources().getDrawable(R.drawable.image1); 

형 주조

Bitmap bitmap = ((BitmapDrawable)drawable).getBitmap(); 

compress 방법을 통해 지정된 OutputStream에 비트 맵의 ​​압축 된 버전을 적는다.

ByteArrayOutputStream out = new ByteArrayOutputStream(); 
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, out); 
byte[] buffer= out.toByteArray(); 
+0

이 답변을 주셔서 감사합니다. 너는 내 시간을 구했다. 감사 +1 –

0

아마도 자원 클래스의 openRawResource 함수를 사용하고 싶을 것이다. 그것은 당신에게 InputStream을 줄 것입니다. 그런 다음 스트림을 사용하여 원시 바이트 배열을 가져올 수 있습니다 (read 함수 사용).

관련 문제