Donghua,

In your code with HttpClient you assume that the whole image will be passed
to you by the server in 1 go.

You should be reading from the input stream to a buffer in a loop and only
when the server sends EOF, you should be turning received bytes into an
image.

HTH,

Daniel







On 4 March 2013 10:23, Donghua <[email protected]> wrote:

> I have a webserver which convert all jpg/png pictures to webp format, now
> I face some problems when showing the remote webp image(larger webp
> pictures with high probability ) in ImageView of my android client.
> Like the following picture shows, the image rendered is only a partial.
>
>
> <https://lh4.googleusercontent.com/-xAbynAwyUtw/UTRrAC7b2SI/AAAAAAAAACo/JJTk6L5kDOE/s1600/sshot-1.png>
> I use HttpClient to get the remote webp image inputstream, and wraped the
> inputstream with BufferedInputStream/FlushedInputStream/PatchInputStream(
> https://code.google.com/p/android/issues/detail?id=6066)
> but none of them works. below is the relevant code
>
> *InputStream is = null;
> *
> *HttpClient httpClient = new DefaultHttpClient();*
> *HttpGet httpGet = new HttpGet(webp_image_url);*
> *HttpResponse response = httpClient.execute(httpGet);*
> *is = response.getEntity().getContent();*
> *// is = new BufferedInputStream(response.getEntity().getContent());*
> *// is = new FlushedInputStream(response.getEntity().getContent());
> *
> *// is = new PatchInputStream(response.getEntity().getContent());
> *
> *// get Bitmap using BitmapFactory.decodeStream
> *
> *bm = BitmapFactory.decodeStream(is);*
> *mImageView.setImageBitmap(bm);*
>
> However, if I use URLConnection or open the the inputstream
> locally(download to the local and save as a file) then it
> works miraculously.
>
> *URL url = new URL(webp_image_url);*
> *URLConnection conn = url.openConnection();*
> *conn.connect();*
> *is = conn.getInputStream();*
> *// get Bitmap using BitmapFactory.decodeStream*
> *bm = BitmapFactory.decodeStream(is);*
> *mImageView.setImageBitmap(bm);*
>
> the original png and converted webp picture files are enclosed.
>
> I have tested my web server use libwebp 0.1.2 and libwebp 0.2.1 and my
> android client with galaxy nexus 4.0/4.1/4.2.
>
> Thanks in advance!
>
> --
> You received this message because you are subscribed to the Google Groups
> "Android Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/android-discuss?hl=en.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>



-- 
Daniel Drozdzewski

-- 
You received this message because you are subscribed to the Google Groups 
"Android Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/android-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to