I'm in Android and am trying to convert an object of type Image into Bitmap so to attach it to a Canvas object (Canvas takes bitmap). I convert to InputImage and then try to get bitmap out of it. But inputImage.getBitmapInternal() returns null. How can I fix it? And is there any ways to optimize this code? There is many conversions involved.
Image image = imageReader.acquireLatestImage();
InputImage inputImage = InputImage.fromMediaImage(image, rotation);
Bitmap bitmap= inputImage.getBitmapInternal();
//....
canvas.drawBitmap(bitmap, 0, 0, new Paint(Paint.ANTI_ALIAS_FLAG));
Use this method to convert the
Drawableof yourImageto aBitMap:After that, you can draw it on a
Canvas.