【发布时间】:2012-06-15 08:36:10
【问题描述】:
我正在制作一个显示大量图像的应用程序,这些图像是由 Imagemagick 从 PDF 文件生成的。某些图像,无法使用 BitmapFactory 加载。它只是返回 null 而不是位图。
日志说:
D/skia(15101): --- decoder->decode returned false
这不是内存问题,因为有问题的一些图像非常小,而且图像没有损坏,因为我可以在任何其他机器上显示它们。此外,如果我使用 BitmapFactory 能够解码宽度和高度
inJustDecodeBounds = true;
在选项中。
我尝试使用外部图像查看器 (QuickPic) 加载其中一张图像,但没有成功。它还返回“加载失败”,这表明 SKIA 认为图像已损坏或至少由于某种原因不受支持。
可以找到一张不起作用的图片here
我用来加载它的完整代码在这里
BitmapFactory.Options o = new BitmapFactory.Options();
o.inJustDecodeBounds = true;
BitmapFactory.decodeFile(FILENAME,o);
int width = o.outWidth;
int height = o.outHeight;
/* Width and height decoded successfuly */
BitmapFactory.Options o2 = new BitmapFactory.Options();
o.inJustDecodeBounds = false;
Bitmap bitmap = BitmapFactory.decodeFile(FILENAME,o2);
/*Bitmap is null */
欢迎提出问题或如何规避的任何想法。
【问题讨论】:
-
你能把创建文件名的代码贴出来吗?
-
FILENAME 只是一个引用特定图像文件的常量。在我的例子中,它被定义为'final static String FILENAME = "/sdcard/MPSIT.jpg";'