You are resaving a JPEG. You'll be compressing twice. Why don't you try to directly save the data obtained from the URL to a file on the SDCard. Don't do any compressing. Just a direct save of the JPG file from Flickr.
After you've done that, you have a file (on the SDCard) that contains an exact copy of the image on Flickr. Get hold of the fully qualified file-name of this file. Then you insert a new image into the images' content provider: values.put(MediaStore.MediaColumns.DATA, fullyQualifiedFileName); ... ... Uri uri = mCtx.getContentResolver().insert (Images.Media.EXTERNAL_CONTENT_URI, values); On Feb 1, 4:22 pm, michael <michael.d.peder...@googlemail.com> wrote: > Bump; the post got held up for 2 days due to moderation. > > On Jan 30, 4:53 pm, michael <michael.d.peder...@googlemail.com> 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... > > > 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.- Hide quoted text - > > - Show quoted text - -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en