- Please help i ihave successfully returned photo in the imageview but help me in making it apear circled i have tried the codes
B4X:
Dim SQLQry As String = "DELETE FROM Studentphoto"
Starter.SQL1.ExecNonQuery(SQLQry)
cursor1 = Starter.SQL1.ExecQuery("SELECT phone AS Phone,Sex FROM Register")
If cursor1.RowCount > 0 Then
' For i = 0 To cursor1.RowCount - 1
cursor1.Position =0
Dim Phoneq As String
Phoneq = cursor1.Getstring("Phone")
Dim sx As String
sx = cursor1.Getstring("Sex")
'Next
End If
Dim CustID As String = Phoneq' Customer ID
Dim jtn As HttpJob
jtn.Initialize("", Me)
jtn.Download("http://kccug.com/Generic_Handler_JSON/HandlerVBRegistration.ashx?customerid=" & CustID & "&sx=" & sx)
jtn.GetRequest.Timeout = 10000 ' 10 seconds
Wait For (jtn) JobDone(jtn As HttpJob)
If jtn.Success Then ' if job is success (http status code 200)
Dim RetVal As String
RetVal = jtn.GetString
Log(RetVal)
If jtn.GetString = "[]" Then
'MsgboxAsync("No Records to Upload Yet for: " & CustID ,"SMIS")
Return
Else
Dim jpt As JSONParser
jpt.Initialize(jtn.GetString)
Log(jpt) ' will pr
Dim quotes As List = jpt.NextArray
For Each quot As Map In quotes
Log("Account: " & quot.Get("Account"))
Log("Name: " & quot.Get("Name"))
Log("Category: " & quot.Get("Category"))
' add 1 to the ID number to make a new ID field
Dim CustID As String = quot.Get("Account")
Next
End If
Dim jy As HttpJob
jy.Initialize("", Me)
'j.Download("http://kccug.com/WebServicesula/Service.asmx/Get")
jy.Download("http://kccug.com/Generic_Handler_JSON/HandlerVBPhoto.ashx?customerid=" & CustID)
jy.GetRequest.Timeout = 10000 ' 10 seconds
Wait For (jy) JobDone(jy As HttpJob)
If jy.Success Then ' if job is success (http status code 200)
Dim RetVal As String
RetVal = jy.GetString
If jy.GetString = "[]" Then
'MsgboxAsync("No Records to Upload Yet for: " & CustID ,"SMIS")
Return
Else
Dim jpt As JSONParser
jpt.Initialize(jy.GetString)
Log(jpt) ' will pr
Dim quotes As List = jpt.NextArray
For Each quot As Map In quotes
Log("Account: " & quot.Get("CustomerId"))
Log("Name: " & quot.Get("Name"))
Log("Class: " & quot.Get("Class"))
Log("Stream: " & quot.Get("Stream"))
Log("B6convert: " & quot.Get("B6convert"))
'Dim ktv As String = quot.Get("Byte")
Dim ktb As String = quot.Get("B6convert")
'Dim su As StringUtils
Dim MyBase64StringAsBytes() As Byte = quot.Get("B6convert")
Log( MyBase64StringAsBytes)
'Activity.SetBackgroundImage(Base64StringToImage(ktb))
'ImageView1.SetBackgroundImage(BytesToImage(ktv))
ImageView1.SetBackgroundImage(Base64StringToImage(ktb))
'Starter.SQL1.ExecNonQuery2("INSERT INTO Studentphoto VALUES(?, ?, ?,?,?)", Array As Object(quot.Get("CustomerId"), quot.Get("Name"), quot.Get("Class"),quot.Get("Stream"),Base64StringToImage( quot.Get("base64String")) ))
'hold=quot.Get("CustomerId")
'ReadBlob
Next
End If
End If
Else
MsgboxAsync("Error Connecting to the Server Please Check Your Internet Connection","Server Error")
't1.Enabled = False
Return
End If
B4X:
Sub Base64StringToImage(s As String) As Bitmap
Dim su As StringUtils
Dim bytes() As Byte = su.DecodeBase64(s)
Dim In As InputStream
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
Dim bmp As Bitmap
bmp.Initialize2(In)
In.Close
Return bmp
End Sub
This is what i was trying to use for circling the photo
B4X:
Sub CreateRoundRectBitmap (Input As B4XBitmap, Radius As Float) As B4XBitmap
Dim BorderColor As Int = XUI.Color_Black
Dim BorderWidth As Int = 4dip
Dim c As B4XCanvas
Dim xview As B4XView = XUI.CreatePanel("")
xview.SetLayoutAnimated(0, 0, 0, Input.Width, Input.Height)
c.Initialize(xview)
Dim path As B4XPath
path.InitializeRoundedRect(c.TargetRect, Radius)
c.ClipPath(path)
c.DrawRect(c.TargetRect, BorderColor, True, BorderWidth) 'border
c.RemoveClip
Dim r As B4XRect
r.Initialize(BorderWidth, BorderWidth, c.TargetRect.Width - BorderWidth, c.TargetRect.Height - BorderWidth)
path.InitializeRoundedRect(r, Radius - 0.7 * BorderWidth)
c.ClipPath(path)
c.DrawBitmap(Input, r)
c.RemoveClip
c.Invalidate
Dim res As B4XBitmap = c.CreateBitmap
c.Release
Return res
End Sub