Android Gets Bitmap mode

1, the current project resource files (assets) under the picture

    (1) Obtained picture data stream

 

   private Bitmap getBotMapInfo() {
Bitmap bitmap = null;
try {
InputStream is = mContext.getAssets().open("picture/ic_northeasttycoon.png");
bitmap = BitmapFactory.decodeStream(is);
is.close();
} catch (IOException e) {
e.printStackTrace();
}
return bitmap;
}
(2) 绑定需要的图片
mIv_north_back.setImageBitmap (getBotMapInfo ()); // mIv_north_back page picture ID 
2, to obtain the installation directory android device binding
(1), to obtain current device put pictures directory
String path = Environment.getExternalStorageDirectory () + File.separator + " ic_northeasttycoon.png ";
Bitmap bm = BitmapFactory.decodeFile (path);
(2), bind pictures
mIv_north_back.setImageBitmap (bm);

Guess you like

Origin www.cnblogs.com/northeastTycoon/p/11418928.html