Sub Process_Globals
Dim MYSQLIP = "172.25.0.201" As String
Dim MYSQLDBNAME = "testimg" As String
Dim MYSQLPORT = "3306" As String
Dim MYSQLUSER = "****" As String
Dim MySQLPASS = "****" As String
Dim MySQLConnection As MariaDBConnector
Dim img64 As MF_Image
End Sub
Sub Globals
Dim bBitmap As Bitmap
Dim cPic As Canvas
Dim iPic As ImageView
Dim sImgStr As String
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Connect of database testimg
MySQLConnection.Initialize(MYSQLIP,MYSQLDBNAME,MYSQLUSER, MySQLPASS,MYSQLPORT)
Dim sInsertStatement As String
'Initalize image view
iPic.Initialize("")
'add imagview to activity
Activity.AddView(iPic,1,1,100%x,100%y)
'Create mutable bitmap
bBitmap.InitializeMutable(500,500)
'Initalize canvas to use the bitmap
cPic.Initialize2(bBitmap)
'draw a red circle
cPic.DrawCircle(100,100,50,Colors.Red,True,0)
'encode the canvas bitmap to a stirng
sImgStr = img64.BitmapToString(cPic.Bitmap,100)
'Insert the string into the IMGLIST table in image column
sInsertStatement = "INSERT INTO IMGLIST (imgno, image) VALUES(1," & "'" & sImgStr & "'" & ")"
MySQLConnection.ExecNonQuery("insert",sInsertStatement)
End Sub
Sub insert_error(error As String)
Log (error)
End Sub
Sub insert_complete(updatecount As Int)
'After the insert is completed query the imglist table
MySQLConnection.ExecQuery("query","SELECT * FROM IMGLIST")
End Sub
'"SELECT * FROM IMGLIST" query update
Sub query_update(record As Map)
If record.ContainsKey("image") Then
'Decode the image from a Base64 sring and display it in theIimageview
iPic.Bitmap = img64.StringToBitmap(record.Get("image"))
iPic.Visible = True
End If
End Sub
Sub query_error(error As String)
Log(error)
End Sub
Sub query_complete(finished As Boolean)
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub