I had posted this in another thread, but it was a long running chain and probably got missed, And it deserves a new thread.
Basically, I created a 48x112 pixel preview window by using a label array. background red = on, background grey = off. These are loaded inside a panel. Here is the code, including some test code:
I attached a photo of the subroutine loaded and what it looks like on the screen.
Works great, BUT... it is very very very horrifyingly slow when that thing is visible on the activity window. the whole GUI goes to 386 speeds. and everything becomes laggy and almost unresponsive. Also it takes a very long time for this subroutine to execute of course. But if you hide the panel in the background, everything is fine.
My assumption is because there are now 5,376 tiny little pixel size labels on the screen laid out in a grid, more than the UI rendering engine can handle.
After explaining what I am doing and its inherent problem, is there a more efficient way to layout a preview pixel grid?
Basically, I created a 48x112 pixel preview window by using a label array. background red = on, background grey = off. These are loaded inside a panel. Here is the code, including some test code:
B4X:
Sub CreatePreviewWindow()
Dim x As Int, y As Int
Dim offsetX, offsetY As Int
For X = 0 To 111 Step 1
offsetX = (x * 7) + 25
For y = 0 To 15 Step 1
offsetY = (y * 7) + 25
Dim L As Label
L.Initialize("pixels")
L.Background = PixelOff
pnlPreview.AddView(L, offsetX, offsetY, 7, 7)
Pixels1(x, y) = L
Next
For y = 0 To 15 Step 1
offsetY = (y * 7) + 137
Dim L As Label
L.Initialize("pixels")
L.Background = PixelOff
pnlPreview.AddView(L, offsetX, offsetY, 7, 7)
Pixels2(x, y) = L
Next
For y = 0 To 15 Step 1
offsetY = (y * 7) + 249
Dim L As Label
L.Initialize("pixels")
L.Background = PixelOff
pnlPreview.AddView(L, offsetX, offsetY, 7, 7)
Pixels3(x, y) = L
Next
Next
'Test by setting some random pixels
For X = 0 To 50 Step 1
Pixels1(Rnd(0, 111), Rnd(0, 15)).Background = PixelOn
Pixels2(Rnd(0, 111), Rnd(0, 15)).Background = PixelOn
Pixels3(Rnd(0, 111), Rnd(0, 15)).Background = PixelOn
Next
End Sub
I attached a photo of the subroutine loaded and what it looks like on the screen.
Works great, BUT... it is very very very horrifyingly slow when that thing is visible on the activity window. the whole GUI goes to 386 speeds. and everything becomes laggy and almost unresponsive. Also it takes a very long time for this subroutine to execute of course. But if you hide the panel in the background, everything is fine.
My assumption is because there are now 5,376 tiny little pixel size labels on the screen laid out in a grid, more than the UI rendering engine can handle.
After explaining what I am doing and its inherent problem, is there a more efficient way to layout a preview pixel grid?