iOS Question Merging a canvas to imageview before saving to gallery

Mark Turney

Active Member
Licensed User
Longtime User
I'm drawing freehand (Less Note app) on a canvas which is initialized to a panel. After drawing, it's easy to save the drawing to the photo gallery using:
B4X:
Dim svBmp As Bitmap
    svBmp = cvsDrawPad.CreateBitmap
    Phone.AddImageToAlbum(svBmp)
    tm.ToastMessageShow("Current image saved to Photo Album", False)
However, there is an underlying imageview with various paper types (lined, graph, parchment). I would like to somehow merge the canvas onto the paper type before saving ... so it looks like I drew on the paper (which is just a png).

Any thoughts?

Thanks in advance!
 

MotoMusher

Active Member
Licensed User
Longtime User
Yes, it's pretty easy. You do need to pass the background. This below isn't complete, but just add a second bitmap and assign it to an imageview and add it to photopanel. Add the background first, then the drawing on top.

B4X:
Sub Watermark (Image As Bitmap, background as bitmap) As Bitmap
    Dim PhotoCanvas As Canvas
    Dim PhotoPanel As Panel
    Dim PhotoView As ImageView
    Dim NewImage As Bitmap
   Dim bView As Bitmap
    PhotoPanel.Initialize("")
    PhotoPanel.Width = Image.Width
    PhotoPanel.Height = Image.Height
    PhotoView.Initialize("")
    PhotoView.Bitmap = Image
    PhotoPanel.AddView(PhotoView, 0, 0, Image.Width ,Image.Height)
    PhotoCanvas.Initialize(PhotoPanel)
    NewImage = PhotoCanvas.CreateBitmap
    Return NewImage
End Sub
 
Upvote 0
Top