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
can any one tell me where i have went wrong ?
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)
can any one tell me where i have went wrong ?