Android Question canvas not work in outup file

fifiddu70

Well-Known Member
Licensed User
Longtime User
i have this problem, i have one image and others edittext, in this image about canvas, insert the text, but not show the text in output file, show only image without text, help.

B4X:
Sub btn1_Click
i.Initialize("")
imglogo.Bitmap = LoadBitmap(File.DirAssets, 1.jpg)
b.Initialize(File.DirAssets,  1.jpg)
brect.Initialize(0,0,imglogo.Width, imglogo.Height)

c.Initialize(imglogo)
c.DrawColor(Colors.White)
c.DrawBitmap(b, Null, brect)
c.DrawText(txtnome.Text, 3%x,imglogo.Height-90%y,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 20, Colors.White , "LEFT")
c.DrawText(txtazienda.Text, 3%x,imglogo.Height-75%y,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 35, Colors.Yellow , "LEFT")
c.DrawText(txtdescrizione.Text, 3%x,imglogo.Height-65%y,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 15, Colors.Black, "LEFT")
c.DrawText(txtvia.Text, 3%x,imglogo.Height-50%y,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 18, Colors.Black , "LEFT")
c.DrawText("N°" &" " &  txtnumero.Text & " - " , 3%x,imglogo.Height-42%y,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 18, Colors.Black , "LEFT")
c.DrawText("Cap:" &" " & txtcap.Text, 25%x,imglogo.Height-42%y,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 18, Colors.Black, "LEFT")
c.DrawText(txtluogo.Text, 3%x,imglogo.Height-33%y,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 18, Colors.Black , "LEFT")
c.DrawText("Email:" &" " & txtemail.Text, 3%x,imglogo.Height-21%y,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 18, Colors.White, "LEFT")
c.DrawText("Telefono:" &" " &txttelefono.Text, 30%x,imglogo.Height-10%y,tf.CreateNew(Typeface.SERIF, Typeface.STYLE_BOLD), 18, Colors.Red , "LEFT")

Dim out As OutputStream
    out = File.OpenOutput(File.DirRootExternal, "photo.jpg", False)
    b.WriteToStream(out, 100, "JPEG")
    out.Close
    Msgbox("text insert in image","work ok")
end sub
 

DonManfred

Expert
Licensed User
Longtime User
You load an image to "b" (whatever b is), then you paint on an object named "c" (whatever c is) and then you write b as image back to disc.
You see the error? You write the same image to disc like you loaded into b... You paint on an copy of it.
I think you have to write "c" as new image...
 
Upvote 0
Top