For i = 0 To foto.Size - 1
' controllo invio foto
Dim found As Int
found = dbdata.ExecQuerySingleResult("Select count(*) from sended where d01 = '"&code&"' and d02 = '"&foto.Get(i)&"'")
If found = 0 Then
' load immagine
img.Initialize(pathfoto,foto.Get(i))
c.SetSize(img.Width,img.Height)
c.DrawImage(img,0,0,img.Width,img.Height)
' put watermark
c.DrawImage(wtr,100,(img.Height-wtr.Height)/2,wtr.Width,wtr.Height)
c.DrawImage(wtr,img.Width-(wtr.Width+100),(img.Height-(wtr.Height*2.5)),wtr.Width,wtr.Height)
'write immagine
Dim out As OutputStream = File.OpenOutput(File.DirTemp&"FotoWatermark","base.png",False)
c.Snapshot.WriteToStream(out)
out.close
' from png to jpg
Dim png4jpg As pngTojpg
png4jpg.convert(File.DirTemp&"FotoWatermark\base.png",File.DirTemp&"FotoWatermark\"&foto.Get(i) )
' write sended table
Try
dbdata.BeginTransaction
DateTime.DateFormat = "yyyyMMdd"
dbdata.ExecNonQuery("Insert into SENDED(ID,D01,D02,D03,D04,D05,D06,D07,D08,D09,D10,T01) values(null,'"&code&"','"&foto.Get(i)&"','"&DateTime.Date(DateTime.Now)&"','','','','','','','','')")
dbdata.TransactionSuccessful
Globals.count = Globals.count + 1
Dim Params(1) As Object
Params(0) = Globals.count
OK = False
Do Until OK
Thread1.RunOnGuiThread("Update", Params)
OK = Lock1.WaitFor(1000)
Loop
Catch
Log(LastException)
End Try
End If
Next