1
votes

I am stuck with decoding a jpg file from Image URL location. I tried it with many different solution but unable to decode this.

Could you please give us a try on the following URL and let me know solution.

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;
        }
    }

Also this image successfully decoded by the iPhone Application. is there any limitation to decode image with Android ?

Thanks

1
have you tried to use some kind of image-loader library such as Universal-Android-Image-Loader, Prime, etc ... ? They have this kind of problems sorted out the most :-)Marek Sebera
@MarekSebera Yes I tried the Universal-Android-Image-Loader also.Himanshu

1 Answers

-1
votes

There is issue with Image, that image is skia graphics enabled so you are facing this issue.