gpt4 book ai didi

android - 位图总是显示为空?

转载 作者:行者123 更新时间:2023-11-30 03:09:33 25 4
gpt4 key购买 nike

在我的程序中,我必须将图像路径更改为位图。图像路径已经退出,但是当我更改为位图时,位图始终显示为空。我不知道发生了什么。这是我的代码。

String dirName = Environment.getExternalStorageDirectory().toString()+picturePath;
File sddir = new File(dirName);

Bitmap myBitmap = BitmapFactory.decodeFile(sddir.getAbsolutePath());
//Drawable d = new BitmapDrawable(getResources(), myBitmap);
Log.i("mybitmap",myBitmap+"");

Log.i("dirName",dirName+"");
Log.i("FileName",sddir+"");

请给我一些建议...

编辑:Logcat 输出:

01-19 11:56:18.085: I/mybitmap(1469): null
01-19 11:56:18.085: I/dirName(1469): /mnt/sdcard/mnt/sdcard/447650.jpg
01-19 11:56:18.085: I/FileName(1469): /mnt/sdcard/mnt/sdcard/447650.jpg
01-19 12:19:59.754: I/PicturePath(1671): /mnt/sdcard/62afbdb0c0d287195c0eb7793427b8b8.jpg

最佳答案

您的位图路径错误,您将路径附加到 sdcard 两次。试试这个:

Bitmap myBitmap = BitmapFactory.decodeFile("/mnt/sdcard/447650.jpg");

Bitmap myBitmap = BitmapFactory.decodeFile(picturePath);

picturePath设为相对于sdcard路径的路径。

关于android - 位图总是显示为空?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21213423/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com