3 回答

TA貢獻(xiàn)1853條經(jīng)驗(yàn) 獲得超18個(gè)贊
//Convert to byte arrayByteArrayOutputStream stream = new ByteArrayOutputStream();bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);byte[] byteArray = stream.toByteArray();Intent in1 = new Intent(this, Activity2.class);in1.putExtra("image",byteArray);
byte[] byteArray = getIntent().getByteArrayExtra("image");Bitmap bmp = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
編輯
try { //Write file String filename = "bitmap.png"; FileOutputStream stream = this.openFileOutput(filename, Context.MODE_PRIVATE); bmp.compress(Bitmap.CompressFormat.PNG, 100, stream); //Cleanup stream.close(); bmp.recycle(); //Pop intent Intent in1 = new Intent(this, Activity2.class); in1.putExtra("image", filename); startActivity(in1);} catch (Exception e) { e.printStackTrace();}
Bitmap bmp = null;String filename = getIntent().getStringExtra("image");try { FileInputStream is = this.openFileInput(filename); bmp = BitmapFactory.decodeStream(is); is.close();} catch (Exception e) { e.printStackTrace();}

TA貢獻(xiàn)1877條經(jīng)驗(yàn) 獲得超1個(gè)贊

TA貢獻(xiàn)1845條經(jīng)驗(yàn) 獲得超8個(gè)贊
intent.putExtra("uri", Uri);
Bitmap bitmap = MediaStore.Images.Media.getBitmap(this.getContentResolver(),Uri.parse(uri));
- 3 回答
- 0 關(guān)注
- 445 瀏覽
添加回答
舉報(bào)