Android Question How to compress the captured photos and then transfer them to Panel1 using this code?

bskotu555

Active Member
B4A:
Private Sub ShowMedia (Result As MediaChooserResult)
    If Result.Success Then
        smm.SetMediaFromFile(Panel1, Result.MediaDir, Result.MediaFile, Result.Mime, Null)
    Else
        Panel1.RemoveAllViews
    End If
End Sub
Sometimes the sentence 'Panel1. MoveAllViews' cannot clear the background image, I don't know what the situation is...
 

bskotu555

Active Member
How is the thread title related to the question?

You will need to add more information. Is this the only place where you set the image?


B4A:
Private Sub Button1_Click
    Wait For (chooser.CaptureImage) Complete (Result As MediaChooserResult)
    ShowMedia(Result)
End Sub

Private Sub ShowMedia (Result As MediaChooserResult)
    If Result.Success Then
        smm.SetMediaFromFile(Panel1, Result.MediaDir, Result.MediaFile, Result.Mime, Null)
    Else
        Panel1.RemoveAllViews
    End If
End Sub
B4A:
Private Sub Button3_Click
    If EditText1.Text<>"" Then
        Dim outStream As OutputStream
        StartService(Starter)
        Dim tx As String=EditText1.Text
        outStream.InitializeToBytesArray(0)
        Panel1.Snapshot.WriteToStream(outStream, 100, "PNG")
        Dim ar() As Byte = outStream.ToBytesArray
        Starter.Mysql_Jdbc.ExecNonQuery2( "insert into 料库(料图名,料图) VALUES(?, ?)", Array As Object(tx,ar))
        EditText1.Text =""
        Panel1.RemoveAllViews
        EditText1.RequestFocus
        MsgboxAsync("上传成功!","提示")
    Else
        MsgboxAsync("信息不全,禁止上传!","警告")
    End If
End Sub
Click the button to take a photo, then load the image into the Panel1 control, and upload the image from Panel1 to the MySQL database. Currently, the process has been completed, but the image uploaded to the MySQL database is too large. I want to compress it before uploading
 
Upvote 0
Top