Sub Cam_Complete (Success As Boolean, Image As Bitmap, VideoPath As String)
If Success Then
Dim esvideo As Boolean
If VideoPath = Null Then
esvideo = False
Else if VideoPath.Contains("/") Then
esvideo = True
VideoPath = Null
End If
If esvideo = True Then
HD.ToastMessageShow("Just images",False)
Else if esvideo = False Then
SaveBitmap(CreateScaledBitmap2(Image,721,1280),"imageselected.png",File.DirDocuments,500) 'THIS IS
pgFoto.Initialize("pgFoto")
pgFoto.RootPanel.Color = Colors.Transparent
pgFoto.RootPanel.LoadLayout("pgFoto")
pgFoto.RootPanel.Alpha = 1
imgZoom.GetBase.SetBorder(0,Colors.Transparent,0)
imgZoom.GetBase.Color = Colors.Transparent
imgZoom.Bitmap = LoadBitmap(File.DirDocuments,"imagemodificable.png")
imgZoom.MaxScale = 100%x
Main.NavControl.ShowPage(pgFoto)
End If
End Sub
Sub CreateScaledBitmap (Image As Bitmap, Width As Int, Height As Int) As Bitmap
Dim PhotoCanvas As Canvas
Dim PhotoPanel As Panel
Dim PhotoView As ImageView
Dim NewImage As Bitmap
PhotoPanel.Initialize("")
PhotoPanel.Width = Width / 2
PhotoPanel.Height = Height / 2
PhotoView.Initialize("")
PhotoView.Bitmap = Image
PhotoPanel.AddView(PhotoView,0,0,Width / 2,Height / 2)
PhotoCanvas.Initialize(PhotoPanel)
NewImage = PhotoCanvas.CreateBitmap
Return NewImage
End Sub
Sub SaveBitmap (Image As Bitmap, Filename As String, Dir As String, Quality As Int) As Boolean
Dim Result As Boolean= True
Dim out As OutputStream = File.OpenOutput(Dir, Filename, False)
Dim data() As Byte = GetByteFromBitmap(Image, Quality)
Try
out.WriteBytes(data, 0, data.Length)
Catch
Result = False
End Try
out.Close
Return Result
End Sub
Sub GetByteFromBitmap(img As Bitmap, Quality As Int) As Byte()
Dim out As OutputStream
Dim data() As Byte
out.InitializeToBytesArray(1)
img.WriteToStream(out,Quality,"PNG")
data = out.ToBytesArray
out.Close
Return data
End Sub