0

嗨,我有这段代码,如何将图像转换为位图?我正在从画廊访问图像。

_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();


    }
4

2 回答 2

0

这是为实现此目的而给出的完整示例:

从图库中选择图像

谢谢。

于 2013-01-22T00:20:16.450 回答
0

如果要将图像获取到 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");
于 2013-01-22T01:08:15.213 回答