RishiKumar2210
Active Member
I want to convert Images to Bytes. I Attached Error Image
The Following is the error message
java.lang.IllegalArgumentException: No enum constant android.graphics.Bitmap.CompressFormat.
B4X:
Public Sub ImageToBytes(Image As Bitmap) As Byte()
If is_imageextension = "png" Then
Dim ls_imageformat As String = "PNG"
Else IF is_imageextension = "jpg" Or is_imageextension = "jpeg" Then
Dim ls_imageformat As String = "JPEG"
End If
Dim out As OutputStream
out.InitializeToBytesArray(0)
Image.WriteToStream(out, 100, ls_imageformat)
out.Close
Return out.ToBytesArray
End Sub
B4X:
Dim ls_photostring As String = ""
Dim ls_byte() As Byte
ibit_bitmap = image_imageview.Bitmap
ls_byte = ImageToBytes(ibit_bitmap)
Log(2)
Dim ls_stringutils As StringUtils
ls_photostring = ls_stringutils.EncodeBase64(ls_byte)
The Following is the error message
java.lang.IllegalArgumentException: No enum constant android.graphics.Bitmap.CompressFormat.