androidbitmapdithering

Bitmap appearance is not looking good, dithering is not working, in Android


I want to use coverflow view in my app. To get the reflection image part i have used the following code - http://www.androidsnippets.com/create-image-with-reflection

I have seen lot of forums/discussions about dithering and tileMode, I have tried all that discussed but nothing works for me.

FYI - I am creating a bitmap dynamically not using any bitmap in layouts. And I have attached the image to show how bad it is:

Reflection image appearance is not looking good

I have listed below what I have tried to solve this issue.

   1. getWindow().setFlags(WindowManager.LayoutParams.FLAG_DITHER, WindowManager.LayoutParams.FLAG_DITHER);

   2. getWindow().setFormat(PixelFormat.RGBA_8888);


   3. BitmapDrawable baseImageDawable = new BitmapDrawable(getResources().openRawResource(imageId));
      baseImageDawable.setDither(true);
      baseImageDawable.setTileModeXY(Shader.TileMode.REPEAT, Shader.TileMode.REPEAT);

      Bitmap originalImage = baseImageDawable.getBitmap();
      int width = originalImage.getWidth();
      int height = originalImage.getHeight();

      Bitmap reflectionImage = Bitmap.createBitmap(originalImage, 0, 0, width, height, matrix, true);   

But still the reflection image is very ugly.

How can I solve this?


Solution

  • I found the location where should I set the config. While creating the reflection bitmap set the config as ARGB_8888. Its working now.