B4J Question Label Array to Bitmap

Blueforcer

Well-Known Member
Licensed User
Longtime User
Hi,

i have 32x8 panels. im able to change the color of this pixels. so it looks like im drawing on a 32x8 pixel pic.
i store all informations about this "pixels" in an array ( Dim Labels(32, 8) As Label). How can i convert this array to a bitmap?
 

Cableguy

Expert
Licensed User
Longtime User
Use a canvas and after "drawing" the stored info, use the canvas methods to retrieve the bitmap
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Don't use labels at all. Use a canvas instead.

Complete code:
B4X:
Sub Process_Globals
   Private fx As JFX
   Private MainForm As Form
   Private Canvas1 As Canvas
   Private BoxWidth, BoxHeight As Float
End Sub

Sub AppStart (Form1 As Form, Args() As String)
   MainForm = Form1
   MainForm.RootPane.LoadLayout("1") 'Load the layout file.
   MainForm.Show
   BoxWidth = Canvas1.Width / 32
   BoxHeight = Canvas1.Height / 8
End Sub

Sub Canvas1_MouseDragged (EventData As MouseEvent)
   Dim xy() As Int = ScreenPointToGridPoint(EventData.X, EventData.Y)
   Canvas1.DrawRect(xy(0) * BoxWidth, xy(1) * BoxHeight, BoxWidth, BoxHeight, fx.Colors.Red, True, 0)
End Sub

Sub ScreenPointToGridPoint (x As Float, y As Float) As Int()
   Return Array As Int(x / BoxWidth, y / BoxHeight)
End Sub
 
Upvote 0
Top