Sub PrepareSurface As ResumableSub
SetState(False, busystate, VideoMode)
'sizes can be modified here
If VideoMode Then
cam.PreviewSize.Initialize(640, 480)
'Using a temporary file to store the video.
Wait For (cam.PrepareSurfaceForVideo(MyTaskIndex, VideoFileDir, "temp-" & VideoFileName)) Complete (Success As Boolean)
Else
cam.PreviewSize.Initialize(544, 416)
Wait For (cam.PrepareSurface(MyTaskIndex)) Complete (Success As Boolean)
End If
If Success Then cam.StartPreview(MyTaskIndex, VideoMode)
SetState(Success, busystate, VideoMode)
Return Success
End Sub
Sub TakePicture
Try
SetState(openstate, True, VideoMode)
Wait For(cam.FocusAndTakePicture(MyTaskIndex)) Complete (Data() As Byte)
SetState(openstate, False, VideoMode)
Dim bmp As Bitmap = cam.DataToBitmap(Data)
If frontCamera Then
bmp = bmp.Rotate(270)
Else
bmp = bmp.Rotate(90)
End If
Log("Picture taken: " & bmp)
pnlBackground.SetVisibleAnimated(100, True)
pnlPicture.SetBackgroundImage(bmp.Resize(pnlPicture.Width, pnlPicture.Height, True)).Gravity = Gravity.CENTER
Sleep(4000)
pnlBackground.SetVisibleAnimated(500, False)
atendimento.mFoto = bmp
Catch
HandleError(LastException)
End Try
End Sub
Sub Activity_Resume
If ImgMT_Imagem.IsInitialized And mFoto.IsInitialized And mTipo_Foto = "Procedimento" Then
ImgMT_Imagem.Bitmap = mFoto
End If
If ImgCL_Foto.IsInitialized And mFoto.IsInitialized And mTipo_Foto = "Cadastro" Then
ImgCL_Foto.Bitmap = mFoto
Dim mImagem() As Byte
If ImgCL_Foto.Bitmap = Null Then
mImagem = Null
Else
mImagem = CreateRequest.ImageToBytes(ImgCL_Foto.Bitmap)
End If
Dim cmd1 As DBCommand = CreateCommand("update_cliente", Array(mImagem, mCod_Cliente))
Dim j1 As HttpJob = CreateRequest.ExecuteBatch(Array(cmd1), Null)
Wait For(j1) JobDone(j1 As HttpJob)
If j1.Success Then
ToastMessageShow("Foto Atualizada !!!",False)
Else
ToastMessageShow("Erro ao Gravar Foto !!!",False)
End If
j1.Release
End If
mTipo_Foto = ""
End Sub