I'm trying to test the example code from @JordiCP to find out how it works. I need to create a program that will collage images from a folder and save as one file.
But I'm getting this error
I'm using library X2, jXUI, B4XCollections, jFx, jCore
What library am I missing?
B4X:
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
Private ImageView1 As B4XView
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
End Sub
Sub Button1_Click
''xui.MsgboxAsync("Hello World!", "B4X")
Dim myBitmap(8) As B4XBitmap
' ... init them
myBitmap.xui.LoadBitmapResize(File.DirAssets,"1.png", ImageView1.Width, ImageView1.Height, False)
myBitmap.xui.LoadBitmapResize(File.DirAssets,"2.png", ImageView1.Width, ImageView1.Height, False)
myBitmap.xui.LoadBitmapResize(File.DirAssets,"3.png", ImageView1.Width, ImageView1.Height, False)
Dim scaleFactor As Float=1 ' or whatever
Dim W As Int = scaleFactor*myBitmap(0).Width ' We are assuming that all bitmaps have equal dimensions.
Dim H As Int = scaleFactor*myBitmap(0).Height
Dim totalW As Int = 4*W ' Total width of 4*2 mosaic
Dim totalH As Int = 2*H ' Total height ...
Dim b As B4XBitmap
b.initializeMutable(totalW,totalH)
Dim cv As Canvas
cv.initialize2(b)
For r=0 To 1
For c=0 To 3
Dim dstRect As Rect
dstRect.initialize(c*W, r*H, (c+1)*W, (r+1)*H) '<-- each bitmap will be in a position in the mosaic. No spacing between bitmaps here
cv.drawBitmap( myBitmap(4*r+c), Null, dstRect)
Next
Next
' Now you have your bitmap in b and also in cv.bitmap. Can be saved to jpeg
Dim o As OutputStream
o=File.OpenOutput("c:\", "collage1.png",False)
cv.Bitmap.WriteToStream(o,100,"PNG") 'or "PNG"
o.Close
End Sub
B4X:
Unknown type: game: Are you missing a library reference?
What library am I missing?
Last edited: