[英]how to convert image into bitmap
嗨,我有這段代碼,如何將圖像轉換為位圖? 我正在從畫廊訪問圖像。
_GaleryButton.setOnClickListener(new View.OnClickListener()
{
public void onClick(View v) {
// TODO Auto-generated method stub
Intent intent=new Intent();
intent.setAction(Intent.ACTION_PICK);
intent.setData(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI);
startActivity(intent);
}
});
}
protected void onGActivityResult(int GrequestCode, int GresultCode, Intent Gdata){
super.onActivityResult(GrequestCode,GresultCode,Gdata);
Uri uriimg = Gdata.getData();
}
如果要將圖像保存到SD卡,請使用此代碼
//Get the root of your sd card
File sdcard = Environment.getExternalStorageDirectory();
//Folder from sd card
File storagePath = new File(sdcard.getAbsolutePath() + "/fb_image");
//Decode the file from the folder to bitmap
Bitmap bmp = BitmapFactory.decodeFile(storagePath + "/" + file_name+ ".jpg");
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.