Bump; the post got held up for 2 days due to moderation.

On Jan 30, 4:53 pm, michael <[email protected]> wrote:
> Hi,
>
> I am working on an app that displays photos which are downloaded from
> Flickr. I obtain a Bitmap object from a byte array, which in turn is
> read from the relevant Flickr URL, as follows:
>
> Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
>
> The problem is that the resulting bitmap is pixelated and I can't
> figure out why. To demonstrate, here is an example of a picture
> created via BitmapFactory.decodeByteArray versus the original picture
> obtained directly from the relevant Flickr URL:
>
> http://homepages.inf.ed.ac.uk/s0677975/bad.jpghttp://homepages.inf.ed.ac.uk/s0677975/good.jpg
>
> Look e.g. at the clouds in the top-left corner to see the difference.
>
> Can anybody give me a hint as to why this is happening?
>
> Below are some additional details. The byte array is obtained as
> follows; this is based on code from the Photostream app by Romain Guy:
>
> InputStream in = new BufferedInputStream(url.openStream(),
> IO_BUFFER_SIZE);
> final ByteArrayOutputStream dataStream = new ByteArrayOutputStream();
> out = new BufferedOutputStream(dataStream, IO_BUFFER_SIZE);
> copy(in, out);
> out.flush();
> final byte[] data = dataStream.toByteArray();
>
> Note that the more direct approach using e.g.
> BitmapFactory.decodeStream() does not work; see e.g. the following
> discussion for details:
>
> http://markmail.org/message/m2m3cpkh6ggrvj43#query:BitmapFactory.deco...
>
> Here is the code I used for writing the bitmap to the JPG file linked
> to above, with no compression:
>
> String filename = "test" ;
> ContentValues values = new ContentValues();
> values.put(Images.Media.TITLE, filename);
> values.put(Images.Media.DATE_ADDED, System.currentTimeMillis());
> values.put(Images.Media.MIME_TYPE, "image/jpeg");
>
> Uri uri = mCtx.getContentResolver().insert
> (Images.Media.EXTERNAL_CONTENT_URI, values);
> try {
>   OutputStream outStream = mCtx.getContentResolver().openOutputStream
> (uri);
>   bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outStream);
>   outStream.flush();
>   outStream.close();} catch (FileNotFoundException e) {}
>
>   catch (IOException e) {}
>
> Any help on this matter would be greatly appreciated.
> Thanks and best regards,
> Michael.

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to