//******************
// uri image -> byte[]
//******************
InputStream is = (InputStream) new URL(url).getContent();
Bitmap bmp = BitmapFactory.decodeStream(is);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
//******************
// Bitmap -> byte array
//******************
Bitmap bmp = intent.getExtras().get("data");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
//******************
// Select
//******************
Cursor cs = ...
...
byte[] image = cs.getBlob(cs.getColumnIndex("blob_attr"));
Bitmap bitmap = BitmapFactory.decodeByteArray(image, 0, image.length);
-bitmap -> byte array
http://stackoverflow.com/questions/4989182/converting-java-bitmap-to-byte-array
댓글
댓글 쓰기