I use Camera2 to make pictures in my app. In some of these pictures, I need to know the compass orientation, so I've overlaid a compass over the camera preview, and I need to save the image with the overlaid compass.
I've tried to define
B4X:
pnlCamera as B4XView
..
cam.Initialize(pnlCamera)
...
Dim bmp As B4XBitmap = pnlCamera.Snapshot
But I get a black screen with the compass and the views in the pnlCamera, but not the image itself.
The resulting image is too small too (about 19kb).
I've been reading about BitmapCreator, but not sure if it's what I need. Maybe with this I could save the image as always, the pnlCamera.Snapshot and overlay them?
Dim bmp As B4XBitmap = cam.DataToBitmap(Data)
Dim bmp2 As B4XBitmap = LoadBitmap(File.DirAssets, "android-chrome-192x192.png")
Dim bc As BitmapCreator
bc.Initialize(bmp.Width, bmp.Height)
bc.CopyPixelsFromBitmap(bmp)
Dim r As B4XRect
r.Initialize(20dip, 20dip, 0, 0)
r.Width = bmp2.Width
r.Height = bmp2.Height
bc.DrawBitmap(bmp2, r, False)
Dim mergedbmp As B4XBitmap = bc.Bitmap
I've been reading about DrawBitmapCreator, searching about transparency...
In the thumbnail it seems to work, but in the image I don't get the compass with transparent background.
I've changed the line
B4X:
bc.DrawBitmap(bmp2, r, False)
with
B4X:
bc.DrawBitmapCreator(bc,r,50,50,True)
but no success...
B4X:
Dim bmp As B4XBitmap = cam.DataToBitmap(Data)
Dim bmp2 As B4XBitmap = pnlCompass.Snapshot
Dim bc As BitmapCreator
bc.Initialize(bmp.Width, bmp.Height)
bc.CopyPixelsFromBitmap(bmp)
Dim r As B4XRect
r.Initialize(20dip, 20dip, 0, 0)
r.Width = bmp2.Width
r.Height = bmp2.Height
bc.DrawBitmapCreator(bc,r,50,50,True)
Dim mergedbmp As B4XBitmap = bc.Bitmap