0

I am trying to draw bitmap on canvas of its size (fullscreen), thus I wrote below code:

Bitmap bm= BitmapFactory.decodeResource(getContext().getResources(), R.drawable.level_bg);
Rect dest = new Rect(0, 0, getWidth(), getHeight());
canvas.drawBitmap(bm, null, dest, paint);

but I am getting some horizontal lines over the image as shown in picture. screenshot

I also tried below code:

BitmapFactory.Options options = new BitmapFactory.Options();
options.inScaled = false;
options.inDither = false;
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap bm = BitmapFactory.decodeResource(getContext().getResources(), R.drawable.level_bg, options);
Paint paint = new Paint();
paint.setFilterBitmap(true);
canvas.drawBitmap(bm, null, dest, paint);

Any help ?

  • [This may help, I found a similar question: http://stackoverflow.com/a/4822358/4479310](http://stackoverflow.com/a/4822358/4479310) – PEF Sep 10 '16 at 22:55
  • @PEf it didn't work. any other work around ? – androoo Sep 11 '16 at 12:18

1 Answers1

0

I'd check to see if this happens to other images (try some random ones). It's possible the image you are displaying is being stretched too much if it is too low resolution to begin with or it may have too small a color bit-depth.

PEF
  • 207
  • 1
  • 4
  • 11