如何从位图一个Uri对象位图、对象、Uri

由网友(狗咬狗一嘴毛)分享简介:在一定的敲击事件,我要求用户添加一个图像。所以,我提供了两个选项:On a certain tap event, I ask the user to add an image. So I provide two options: 要由画廊添加。要请从相机的新形象。我的目标就是保持与这些图像URI的List。My...

在一定的敲击事件,我要求用户添加一个图像。所以,我提供了两个选项:

On a certain tap event, I ask the user to add an image. So I provide two options:

要由画廊添加。 要请从相机的新形象。

我的目标就是保持与这些图像URI的List。

My aim is to keep a list of "uri"s related to those images.

如果用户选择库,然后我得到的图像URI(这是很简单的)。 但是,如果他选择的相机,然后拍摄照片后,我得到了画面的位图对象。

If the user chooses gallery, then I get the image uri (which is quite simple). But if he chooses camera, then after taking a picture, I am getting the Bitmap object of that picture.

现在我怎么转换成位图对象的URI,或者换句话说,我怎么能得到那个位图对象的相对Uri对象?

Now how do I convert that Bitmap object to uri, or in other words, how can I get the relative Uri object of that bitmap object?

感谢。

推荐答案

我有同样的问题,在我的项目,所以我按照简单的方法(的点击此处)从位图获得URI。

I have same problem in my project, so i follow the simple method (click here) to get Uri from bitmap.

public Uri getImageUri(Context inContext, Bitmap inImage) {
  ByteArrayOutputStream bytes = new ByteArrayOutputStream();
  inImage.compress(Bitmap.CompressFormat.JPEG, 100, bytes);
  String path = Images.Media.insertImage(inContext.getContentResolver(), inImage, "Title", null);
  return Uri.parse(path);
} 
阅读全文

相关推荐

最新文章