android 把assets 里面的图片文件输出到SD卡
//從項目取出來,大家一起看看,android 把assets 里面的圖片文件輸出到SD卡
private void sWithImage(String image) {
// TODO Auto-generated method stub
AssetManager asm=getAssets();
//選擇默認圖片
InputStream is;
try {
/* is = asm.open("member_defautpictue.png");
Drawable da = Drawable.createFromStream(is, null);
Bitmap bitmap=BitmapFactory.decodeStream(is);
ByteArrayOutputStream stream = new ByteArrayOutputStream();
?
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);// (0
// -
*/
//Log.i("i", ",mMemberImage = " + mMemberImage);
//得到assets里面的圖片名
InputStream ist = asm.open("member_defautpictue.png");
? ? ? ? Bitmap ? images = BitmapFactory.decodeStream(ist);
//輸出到SD卡上
? ? ? ? ? ?FileOutputStream out = new FileOutputStream(Environment
.getExternalStorageDirectory() + "/temp1.jpg"); ? ? ? ? ? ?
? ? ? ? ? ?images.compress(Bitmap.CompressFormat.PNG,100,out); ? ? ? ? ? ? ??
? ? ? ? mMemberImage ?= bitmaptoString( images);
? ? ? ? ? ?out.flush();
? ? ? ? ? ?out.close(); ? ? ? ? ? ?
? ? ? ? ? ?ist.close();
? ? ? ? ? ?
? ? ? ? ? ?
} catch (java.io.IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
總結
以上是生活随笔為你收集整理的android 把assets 里面的图片文件输出到SD卡的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 五十元人民币是哪一年发行的
- 下一篇: 杜小满金融是什么