【问题标题】:How can I get the image path of an image inside an image view?如何在图像视图中获取图像的图像路径?
【发布时间】:2012-06-08 15:59:15
【问题描述】:

我在图像视图中设置了缩放图像。现在我想得到那个缩放图像的路径。那可能吗?我听说它存储在内部存储器的某个地方。

更新:

我有这个问题:我在 imagview 中设置了一组来自图库的图像。我现在想要的是保存这个状态(这意味着图像视图中的图像)。我该怎么做?

我考虑将带有 blob 的整个图像保存到我的 SQL 数据库中。但是后来我听说应该宁愿走图像路径。

谁能告诉我该怎么做?

这就是我从图库中获取图像以及在 ImageView 中设置它的方式。

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (resultCode == RESULT_OK) {
        if (requestCode == PICK_FROM_FILE) {
            Uri selectedImageUri = data.getData();
            selectedImagePath = getPath(selectedImageUri);

            Log.v("IMAGE PATH====>>>> ",selectedImagePath);

            // Decode, scale and set the image.
            Bitmap myBitmap = BitmapFactory.decodeFile(selectedImagePath);
            Bitmap scaledBitmap = Bitmap.createScaledBitmap(myBitmap, NEW_WIDTH, NEW_HEIGHT, true);
            myBitmap.recycle();
            myBitmap = null;

            mImageView.setImageBitmap(scaledBitmap);
        }
    }
}

【问题讨论】:

    标签: android image path imageview


    【解决方案1】:

    试试这个

    String filename = "myfilename"
    FileOutputStream out = new FileOutputStream(filename)
    scaledBitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
    

    还有更多关于如何保存位图对象here的示例。

    【讨论】:

      猜你喜欢
      • 2012-06-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多