So, I have 2 views that I need to combine into 1 "JPEG" image...
But I just can't make sense of canvas!!!
My Logic is, I create a blank, parentless canvas, to which I set the Image from a B4XImageView.
Then I take a snapshot of an "overlay" Panel and add it to the Canvas.
Then, Finally, export it to jpeg file.
But since canvas is an "invisible" thing, I just don't know what I am doing or why it doesn't work!
Private Sub Button1_Click
fx.Clipboard.SetImage(Pane1.Snapshot)
End Sub
Private Sub Button2_Click
If fx.Clipboard.HasImage Then
Dim bmp As B4XBitmap = Pane1.Snapshot
Dim fn As String = "filename" & "_" & DateTime.Now & ".jpg"
Dim Out As OutputStream
Out = File.OpenOutput(File.DirTemp, fn, False)
bmp.WriteToStream(Out, 100, "JPEG")
Out.Flush
Out.Close
End If
Dim myBmb As Image =xui.LoadBitmap(File.DirTemp,fn)
Log(myBmb)
B4XImageView2.SetBitmap(myBmb)
End Sub
Simply because the original image is most of the times bigger that the image shown (and thus limited in size) in the pane, and I need to keep the original image size.
Anyway, I got it working, going baby steps at a time.
Private Sub Button1_Click
fx.Clipboard.SetImage(Pane1.Snapshot)
End Sub
Private Sub Button2_Click
If fx.Clipboard.HasImage Then
Dim bmp As B4XBitmap = Pane1.Snapshot
Dim fn As String = "filename" & "_" & DateTime.Now & ".jpg"
Dim Out As OutputStream
Out = File.OpenOutput(File.DirTemp, fn, False)
bmp.WriteToStream(Out, 100, "JPEG")
Out.Flush
Out.Close
End If
Dim myBmb As Image =xui.LoadBitmap(File.DirTemp,fn)
Log(myBmb)
B4XImageView2.SetBitmap(myBmb)
End Sub
As you know, I got it working.
The snapshot as single canvas origin would result in a not optimal image file.
@stevel05 Thanks for the suggestions. Sometimes it's hard to know the views that are best suited for each one's needs.
Anyway, I got it running with "no brand snickers, so why go get some Jordan's?"