Greetings to all
I followed the tutorial of the Advanced Camera bookstore and I am sending the picture I get FTP to a computer ..... my problem is that the picture always looks bad ..... to send while the device is perfectly.
Somebody can help me ?
Thanks
I followed the tutorial of the Advanced Camera bookstore and I am sending the picture I get FTP to a computer ..... my problem is that the picture always looks bad ..... to send while the device is perfectly.
Somebody can help me ?
Thanks
B4X:
#Region Module Attributes
#FullScreen: False
#IncludeTitle: True
#ApplicationLabel: Photo Clinica
#VersionCode: 1
#VersionName:
#SupportedOrientations: landscape
#End Region
'Activity module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim ftp1 As FTP
End Sub
Sub Globals
Dim camera1 As AdvancedCamera
Dim btnTakePicture As Button
Private btnFlash As Button
Dim Panel1 As Panel
Dim paciente As String
Dim nfichero As String
Dim fecha As String
Dim dia As Int
Dim mes As Int
Dim año As Int
Dim hora As Int
Dim minutos As Int
Dim segundos As Int
Private txtbPaciente As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("1")
ftp1.Initialize("ftp1","192.168.1.71",21,"user","pass")
End Sub
Sub Camera1_Ready (Success As Boolean)
If Success Then
camera1.StartPreview
btnTakePicture.Enabled = True
Else
ToastMessageShow("Imposible activar CAMARA", True)
End If
End Sub
Sub Activity_Resume
btnTakePicture.Enabled = False
camera1.Initialize(Panel1, "Camera1")
End Sub
Sub Activity_Pause (UserClosed As Boolean)
camera1.Release
End Sub
Sub Camera1_PictureTaken (Data() As Byte)
dia=DateTime.GetDayOfMonth (DateTime.Now)
mes=DateTime.GetMonth(DateTime.Now)
año=DateTime.GetYear(DateTime.now)
hora=DateTime.GetHour(DateTime.now)
minutos=DateTime.GetMinute(DateTime.now)
segundos=DateTime.GetSecond(DateTime.now)
fecha=dia & mes & año & "_" & hora & minutos & segundos
camera1.StartPreview
Dim out As OutputStream
nfichero="P" & fecha & ".jpg"
paciente="P" & txtbPaciente.text
out = File.OpenOutput(File.DirRootExternal, nfichero, False)
out.WriteBytes(Data, 0, Data.Length)
out.Close
ToastMessageShow("Image saved: " & File.Combine(File.DirRootExternal, nfichero), True)
btnTakePicture.Enabled = True
ftp1.UploadFile(File.DirRootExternal,nfichero,True,"/Users/Domingo/Documents/Pacientes/" & nfichero)
End Sub
Sub ftp1_UploadProgress (ServerPath As String, TotalUploaded As Long, Total As Long)
Dim s As String
s = "Uploaded " & Round(TotalUploaded / 1000) & "KB"
If Total > 0 Then s = s & " out of " & Round(Total / 1000) & "KB"
Log(s)
End Sub
Sub ftp1_UploadCompleted (ServerPath As String, Success As Boolean)
Log(ServerPath & ", Success=" & Success)
If Success = False Then Log(LastException.Message)
End Sub
Sub btnTakePicture_Click
If txtbPaciente.Text="0" Then
ToastMessageShow("Debe introducir un numero de Paciente", True)
Else
btnTakePicture.Enabled = False
'camera1.FocusMode="AUTO"
camera1.PictureSize(800,600)
camera1.TakePicture
End If
End Sub
Sub btnFlash_Click
Dim fl As String
fl=camera1.CurrentFlashMode
If fl= "off" Then
camera1.FlashOn
ToastMessageShow("Flash ON", True)
Else
camera1.FlashOff
ToastMessageShow("Flash OFF", True)
End If
End Sub
Sub Panel1_Click
camera1.FocusMode="AUTO"
End Sub
Sub txtbPaciente_TextChanged (Old As String, New As String)
paciente=txtbPaciente.Text
End Sub