imputStream from a picture background

Prosg

Active Member
Licensed User
Longtime User
hello,

B4X:
Dim InputStream1 As InputStream
    InputStream1 = imgFlashCode.Background
   Dim OutputStream1 As OutputStream
    OutputStream1.InitializeToBytesArray (1000)
    File.Copy2(InputStream1, OutputStream1)
    Dim Buffer() As Byte 'declares an empty array
    Buffer = OutputStream1.ToBytesArray

the imgFlashCode.Background came from httpUtils2 (Download)

B4X:
Select Job.JobName
         Case "Job1"
            'show the downloaded image
            imgFlashCode.SetBackgroundImage(Job.GetBitmap)

i need the outpustream for an insert into a sql lite database (BLOB)


the error is :
javac 1.6.0_26
addclient.java:318: inconvertible types
found : android.graphics.drawable.Drawable
required: java.io.InputStream
_inputstream1.setObject((java.io.InputStream)(mostCurrent._imgflashcode.getBackground()));


Thx for help
 

Prosg

Active Member
Licensed User
Longtime User
thx, i have another similar problem that i have difficult to resolve:

B4X:
Sub Globals
Dim BitmapFlash As Bitmap

I have a sql select :
B4X:
   Cursor1 = SQL1.ExecQuery("SELECT numeroBoite, nomSociete, nomContact, email, qrcode FROM clients where id = " & id)
         For i = 0 To Cursor1.RowCount - 1
         Cursor1.Position = i
         txtNumeroBoite.text = Cursor1.GetString("numeroBoite")
         txtRaisonSociale.text = Cursor1.GetString("nomSociete")
         txtContact.text = Cursor1.GetString("nomContact")
         txtEmail.text =  Cursor1.GetString("email")
         Dim InputStreamFlash As InputStream
         Dim Buffer() As Byte 'declare an empty byte array
          Buffer = Cursor1.GetBlob("qrcode")
          
          InputStreamFlash.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
    
            
          BitmapFlash.Initialize2(InputStreamFlash)
          InputStreamFlash.Close
         imgFlashCode.SetBackgroundImage(BitmapFlash)
         Next
         Cursor1.Close


and in another sub (here is the problem) i have to send this image in an html email:

B4X:
Sub sendFlash_Click
   Dim contenuHtml As String
   contenuHtml = "<img src=" & QUOTE & "data:image/png;base64," & BitmapFlash & QUOTE & " />"

   htmlEmail("[email protected]", "Flash code à imprimer de la société : " & txtRaisonSociale.text, contenuHtml)

end sub



Sub htmlEmail (sEmailDestinataire As String, sSujet As String, sContenu As String)

   If Main.gNomCentre = "" OR Main.gSmtp = "" OR Main.gEmail = "" OR Main.gMotDePasse = ""  Then
      ToastMessageShow("Aucun compte email configuré.", True)
      Return
   End If
   
   'Initialisation du smtp
   Dim SMTP As SMTP
   SMTP.Initialize(Main.gSmtp, Main.gPort,  Main.gEmail, Main.gMotDePasse,  "SMTP")
   SMTP.Sender = Chr(34) & Main.gNomCentre & Chr(34) & " <" & Main.gEmail & ">"
    SMTP.UseSSL = Main.gSsl 'Gmail requires SSL.
   SMTP.HtmlBody = True     
   SMTP.To.Add(sEmailDestinataire)
    SMTP.Subject = sSujet
    SMTP.Body = sContenu
  '  SMTP.AddAttachment(File.DirRootExternal, "somefile")
    SMTP.Send
   
End Sub

Many thanks for your help
 
Last edited:
Upvote 0
Top