1

I have a strange problem with an ImageView. I have a partially transparent image with a gradient inside an ImageView. When it renders on the screen, it has banding artifacts in the gradient. Now, I also happen to render it during an animation using this code:

public static Bitmap capture(View view) {
  view.setDrawingCacheEnabled(true);
  Bitmap bitmap = view.getDrawingCache(true);
  bitmap = Bitmap.createBitmap(bitmap);
  view.setDrawingCacheEnabled(false);
  return bitmap;
}

When I render it that way, the banding artifacts disappear! Any ideas how to get rid of the banding on the regular ImageView?

For completeness, the xml code used to create the ImageView looks like

<ImageView android:id="@+id/review_empty_list_icon"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:layout_gravity="center"
  android:layout_margin="10dp" 
  />

I'm populating the image in code using ImageView.setImageResource(int)

The image is a partially transparent image with 24 bit color depth.

Micah Hainline
  • 14,367
  • 9
  • 52
  • 85
  • Could you perhaps post a screenshot or two so we get an idea of what the banding looks like? – tomato Feb 27 '12 at 18:35
  • It's just a grayscale gradient in the image. I don't want to post a screen shot (proprietary & NDA reasons), but check out http://www.photoshopgurus.com/forum/photoshop-newbies/34789-easiest-way-create-gradient-banding.html for an example of what banding looks like. – Micah Hainline Mar 12 '12 at 15:56
  • Take a look at this question, it addresses the same issue: http://stackoverflow.com/questions/4769885/androiddither-true-does-not-dither-whats-wrong – Artur Apr 06 '12 at 03:52

0 Answers0