0

Following overly function working in up to android version 8 but not working in pie :

public static Bitmap overlay(Bitmap bmp1, Bitmap bmp2) {
Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
Canvas canvas = new Canvas(bmOverlay);
canvas.drawBitmap(bmp1, new Matrix(), null);
canvas.drawBitmap(bmp2, 0, 0, null);
return bmOverlay;
}

Desired output getting in below Pie : function's first parameter is output of picture capture and second parameter is bitmap of header view.

Desired output getting in below Pie

Pie output :

enter image description here

View to Bitmap done by :

public static Bitmap viewtoBitmap(View view,int width,int hight){
        Bitmap bitmap=Bitmap.createBitmap(width,hight,Bitmap.Config.ARGB_8888);
        Canvas canvas=new Canvas(bitmap);
        view.draw(canvas);
        return bitmap;
    }
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
earthling
  • 147
  • 16
  • How have you determined that that method is the issue? Have you checked that the `Bitmap`s you're passing into that method are what you're expecting them to be? Also, any particular reason you're using two different `drawBitmap()` methods? – Mike M. Dec 09 '19 at 05:27
  • In pie's output whole Image draw from header view bitmap (base on it's colour).so I think method is issue. I am using two drawBitmap() for draw two different bitmap on one canvas. – earthling Dec 09 '19 at 05:38
  • Yes, but why do you think the problem is in the code you've posted? How do you know that the `Bitmap` you're passing in for `bmp2` isn't wrong? You aren't doing any resizing in the posted code, so I would be more inclined to think that wherever you're creating the "header" is where the problem is, if you're expecting it to be correctly sized already. – Mike M. Dec 09 '19 at 05:41
  • I don't know if I need to resize image ,Inbelow pie method working fine. Second image's position is determine by this canvas.drawBitmap(bmp2, 0, 0, null). – earthling Dec 09 '19 at 05:46
  • Yes, I know how those methods work. I am saying that wherever you're creating `bmp2` is likely where the problem is. – Mike M. Dec 09 '19 at 05:48
  • I update the post. can you review view to bitmap method . – earthling Dec 09 '19 at 05:51
  • That doesn't really help to pinpoint the problem. We have no idea how or when you're calling these methods. Have you debugged at all? Are the values passed into `viewtoBitmap()` correct? As an aside, why are you using a `View` for that header? Why don't you just draw a grey rectangle and those two texts with the `Canvas` in your `overlay()` method? – Mike M. Dec 09 '19 at 05:56
  • I checked all passing and got bitmap . I got corresponding proper bitmap if i save only one of the bitmap from overly method. thank for suggestion i will try drawing gray rectangle stuff . – earthling Dec 09 '19 at 06:05

1 Answers1

0

Below function working fine in Pie(9) and Q(10) Devices :

public static Bitmap mergeBitmap(Bitmap bmp1, Bitmap bmp2) {
        Bitmap bmOverlay = Bitmap.createBitmap(bmp1.getWidth(), bmp1.getHeight(), bmp1.getConfig());
        Canvas canvas = new Canvas(bmOverlay);
        canvas.drawBitmap(bmp1, new Matrix(), null);
        canvas.drawBitmap(bmp2, new Matrix(), null);
        return bmOverlay;
    }
Nensi Kasundra
  • 1,980
  • 6
  • 21
  • 34