I want to write text and save it as .png.
This seems to work with B4A. Although there's a warning about the InitializeMutable units.
I cannot get it to work with B4J. (Warning Bitmap1 not initialized.)
Please tell me where I've gone wrong.
This seems to work with B4A. Although there's a warning about the InitializeMutable units.
B4X:
'create image
Dim Bitmap1 As Bitmap
Bitmap1.InitializeMutable(264, 176)
Dim Canvas1 As Canvas
Canvas1.Initialize2(Bitmap1)
Canvas1.DrawText("Hello", 65dip, 50dip, Typeface.DEFAULT_BOLD, 15, Colors.White, "CENTER")
'save image to file
Dim Out As OutputStream
Out = File.OpenOutput(File.DirRootExternal, "Hello.png", False)
Bitmap1.WriteToStream(Out, 100, "PNG")
Out.Close
I cannot get it to work with B4J. (Warning Bitmap1 not initialized.)
B4X:
'create image
Dim Bitmap1 As Image
Dim Canvas1 As Canvas
Canvas1.Width = 264
Canvas1.Height = 176
Canvas1.Initialize("Bitmap1")
Canvas1.DrawText("Hello", 65, 50, fx.DefaultFont(15), fx.Colors.White, "CENTER")
'save image to file
Dim Out As OutputStream
Out = File.OpenOutput("D:\", "Hello.png", False)
Bitmap1.WriteToStream(Out)
Out.Close
Please tell me where I've gone wrong.
Last edited: