hi I get the following error when trying to load an image file to imageview control
java.lang.RuntimeException: Error loading bitmap.
I am uploading a image file to mysql. and read image record from mysql and trying to laod the same into the control.
following is the code for uploading into mysql
B4X:
Sub InsertImage
Dim su As StringUtils
Dim su1 As String
'convert the image file to a bytes array
Dim InputStream1 As InputStream
InputStream1 = File.OpenInput( File.DirRootExternal, "sign.png")
Dim OutputStream1 As OutputStream
OutputStream1.InitializeToBytesArray(1000)
File.Copy2(InputStream1, OutputStream1)
Dim Buffer() As Byte 'declares an empty array
Buffer = OutputStream1.ToBytesArray
su1=su.EncodeBase64(Buffer)
'write the image to the database
ServerUrl="http://ctor.amwaru.in/insupdatedelete.php"
ExecuteRemoteQuery ("INSERT INTO sigImage(PodNo,SigImage) VALUES(1,'" & su1 & "')",DB_UPDATE)
End Sub
this is how i try to read the mysql record:
Case DB_SHOWIMAGE
Dim gdt As List
Dim cStul As StringUtils
Dim cTmp As String
Dim out As OutputStream
gdt = parser.NextArray 'returns a list with maps
Dim m As Map
Dim Buffer As InputStream
m = gdt.get(i)
cTmp=m.Get("sigimage")
Buffer. InitializeFromBytesArray(cStul.DecodeBase64(cTmp) ,0,1000)
out = File.OpenOutput(File.DirRootExternal,"New.png",False)
File.Copy2(Buffer,out)
out.close
ImageView1 .Bitmap=LoadBitmap(File.DirRootExternal,"New.png")
(here i get the error)
Please use [ code ] tags (without spaces) when posting code.
This thread should have been posted in the questions forum (unless you think that there is a bug).
Please use [ code ] tags (without spaces) when posting code.
This thread should have been posted in the questions forum (unless you think that there is a bug).
Sub Activity_Create(FirstTime As Boolean)
sv.Initialize(300dip)
Activity.AddView(sv, 0dip, 0dip, 320dip, 300dip)
panel1.Initialize("")
sv.Panel.AddView(panel1, 0, 0, sv.Width, 1000dip)
canvas1.Initialize(panel1)
Dim r As Rect
r.Initialize(0,0,320,300)
canvas1.DrawBitmap(c.getimage,Null,r)
canvas1.DrawColor(Colors.ARGB(220,220,220,220))
canvas1.DrawLine(100,0,100.0,300,Colors.RGB(50,50,50),1)
End Sub
B4X:
Sub getimage As Bitmap
Dim bt As Bitmap
bt.Initialize2(dc.DecodeStoB(imagebase64(0))
Return bt
End Sub
The error description is "Invalid number of parentheses." That should give you an hint about the problem, no ? Count the parentheses in your faulty line.