【问题标题】:Unable to decode Image URL --- decoder->decode returned false无法解码图像 URL --- 解码器->解码返回 false
【发布时间】:2013-07-20 10:48:01
【问题描述】:

我无法从图像 URL 位置解码 jpg 文件。 我尝试了许多不同的解决方案,但无法解码。

能否请您尝试以下 URL 并告诉我解决方案。

网址:http://halosys.co.in/FTP-LOCATION/ftp-user15/testing2.jpg

InputStream in = new java.net.URL(imageURL).openStream();
Bitmap bImage = BitmapFactory.decodeStream(new FlushedInputStream(in));
imageView.setImageBitmap(bImage);

static class FlushedInputStream extends FilterInputStream {
        public FlushedInputStream(InputStream inputStream) {
            super(inputStream);
        }

        @Override
        public long skip(long n) throws IOException {
            long totalBytesSkipped = 0L;
            while (totalBytesSkipped < n) {
                long bytesSkipped = in.skip(n - totalBytesSkipped);
                if (bytesSkipped == 0L) {
                    int b = read();
                    if (b < 0) {
                        break;  // we reached EOF
                    } else {
                        bytesSkipped = 1; // we read one byte
                    }
                }
                totalBytesSkipped += bytesSkipped;
            }
            return totalBytesSkipped;
        }
    }

此外,此图像已被 iPhone 应用程序成功解码。用 Android 解码图像有什么限制吗?

谢谢

【问题讨论】:

  • 您是否尝试过使用某种图像加载器库,例如 Universal-Android-Image-Loader、Prime 等...?他们解决这类问题最多:-)
  • @MarekSebera 是的,我也尝试了 Universal-Android-Image-Loader。

标签: android image decoder


【解决方案1】:

图像存在问题,该图像启用了滑雪图形,因此您面临此问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-06-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-03
    • 2015-09-06
    • 2011-09-26
    相关资源
    最近更新 更多