Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Color Banding Solved ooooooooooyyyyyyyeaaaaaaaaaa</p> <p>I solved color banding in two phases</p> <p>1) * when we use the BitmapFactory to decode resources it decodes the resource in RGB565 which shows color banding, instead of using ARGB_8888, so i used BitmapFactory.Options for setting the decode options to ARGB_8888</p> <p>second problem was whenever i scaled the bitmap it again got banded</p> <p>2) This was the tough part and took a lot of searching and finally worked * the method Bitmap.createScaledBitmap for scaling bitmaps also reduced the images to RGB565 format after scaling i got banded images(the old method for solving this was using at least one transparent pixel in a png but no other format like jpg or bmp worked)so here i created a method CreateScaledBitmap to scale the bitmap with the original bitmaps configurations in the resulting scale bitmap(actually i copied the method from a post by logicnet.dk and translated in java)</p> <pre><code> BitmapFactory.Options myOptions = new BitmapFactory.Options(); myOptions.inDither = true; myOptions.inScaled = false; myOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;//important //myOptions.inDither = false; myOptions.inPurgeable = true; Bitmap tempImage = BitmapFactory.decodeResource(getResources(),R.drawable.defaultart, myOptions);//important //this is important part new scale method created by someone else tempImage = CreateScaledBitmap(tempImage,300,300,false); ImageView v = (ImageView)findViewById(R.id.imageView1); v.setImageBitmap(tempImage); </code></pre> <p>// the function</p> <pre><code>public static Bitmap CreateScaledBitmap(Bitmap src, int dstWidth, int dstHeight, boolean filter) { Matrix m = new Matrix(); m.setScale(dstWidth / (float)src.getWidth(), dstHeight / (float)src.getHeight()); Bitmap result = Bitmap.createBitmap(dstWidth, dstHeight, src.getConfig()); Canvas canvas = new Canvas(result); //using (var canvas = new Canvas(result)) { Paint paint = new Paint(); paint.setFilterBitmap(filter); canvas.drawBitmap(src, m, paint); } return result; } </code></pre> <p>Please correct me if i am wrong. Also comment if it worked for you.</p> <p>I am so happy i solved it, Hope it works for you.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload