Aiuto, sto cercando di salvare una foto caricata precedentemente in una ImageView1 ma mi sono arroccato ad un certo punto
non so come passare il dato alla variabile Data dellariga 61
Grazie
non so come passare il dato alla variabile Data dellariga 61
Grazie
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim CC As ContentChooser 'Phone Library
Dim FotoPath = File.DirRootExternal As String 'DirRootExternal 'DirDefaultExternal
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private ButtonGetImage As Button
Private ImageView1 As ImageView
Private ButtonSaveImage As Button
End Sub
Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("Layout1")
CC.Initialize("CC")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub ButtonGetImage_Click
CC.Show("image/*", "Choose image")
End Sub
Sub CC_Result (Success As Boolean, Dir As String, FileName As String)
If Success = True Then
ImageView1.Bitmap = LoadBitmap(Dir,FileName)
Else
ToastMessageShow("No Success :(",True)
End If
End Sub
Sub ButtonSaveImage_Click
ImageToBytes(ImageView1.Bitmap)
Dim out As OutputStream
out = File.OpenOutput(FotoPath, "Camera.jpg", False)
out.WriteBytes(Data, 0, Data.Length)
out.Close
ToastMessageShow("IMMAGINE SALVATA: " & File.Combine(FotoPath, "Camera.jpg"), True)
End Sub
public Sub ImageToBytes(Image As Bitmap) As Byte()
Dim out As OutputStream
out.InitializeToBytesArray(0)
Image.WriteToStream(out, 100, "JPEG")
out.Close
Return out.ToBytesArray
End Sub
Public Sub BytesToImage(bytes() As Byte) As Bitmap
Dim In As InputStream
In.InitializeFromBytesArray(bytes, 0, bytes.Length)
Dim bmp As Bitmap
bmp.Initialize2(In)
Return bmp
End Sub