无法加载的JPEG图像BitmapFactory.de codeFILE。返回空 [英] Unable to load JPEG-image with BitmapFactory.decodeFile. Returns null

查看:157
本文介绍了无法加载的JPEG图像BitmapFactory.de codeFILE。返回空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在做一个应用程序,展示了很多PDF的文件通过ImageMagick的生成的图像。一些图像,不能装入BitmapFactory。它只是返回一个位图的空istead。

I'm making an app that show a lot of images that are generated from PDF-files by Imagemagick. Some of the images, can't be loaded with BitmapFactory. It simply returns null istead of a bitmap.

日志说:

    D/skia(15101): --- decoder->decode returned false

这是不是内存问题,因为一些有问题的图像是非常小的,而且图像不腐败的,因为我可以告诉他们在任何其他机器。此外BitmapFactory能够去code的宽度和高度,如果我使用

It isn't a memory problem as some of the images with the problem is very small, and the images aren't corrupt because I can show them on any other machine. Additionally BitmapFactory is able to decode the width and height if I use

    inJustDecodeBounds = true;

在选项。

我试图加载图像之一与外部图像浏览器(的下载快)没有运气。它还返回加载失败,这表明Skia的认为形象被破坏,或者至少不支持的某些原因。

I've tried to load one of the images with an external Image Viewer (QuickPic) without luck. It also returns "Load failed", which indicates that SKIA believes the image is corrupt or at least not supported for some reason.

一个不能正常工作,可以发现这里图像

One of the images that doesn't work can be found here

完整的code我用它来加载它是在这里

The complete code I use to load it is 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 */

任何想法是错误的或者它如何能够规避是值得欢迎的。

Any idea what is wrong or how it can be circumvented is welcome.

推荐答案

显然的 Skia的有问题以JPG的用CMYK瞩目。解决方法我的问题是参数-colorspace RGB添加到我的ImageMagick的转换。

Apparently SKIA has a problem with JPG's with a CMYK-profile. The workaround for my problem was to add the parameter "-colorspace RGB" to my imagemagick conversion.

这篇关于无法加载的JPEG图像BitmapFactory.de codeFILE。返回空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆