Steps to port the B4J example to B4A and B4i:
0. Update the B4J code to use the latest version of BitmapCreator.
1. Move the relevant code to a class.
2. Share the modules between the projects:
Make sure to select Link and not copy.
3. Create the same layout in B4A and B4i.
4. In B4J and B4i the scale (dots per inch) is always 1. In B4A the scale changes. When working with BitmapCreator we need to divide the dimensions by the scale.
5. The panel events are the same in B4A and B4i. They are a bit different in B4J. This is taken care with:
#if Not (B4J)
Type MouseEvent (X As Int, Y As Int)
Private DummyPanel As Panel 'ignore
#End If
#if Not(B4J)
Sub Pane1_Touch (Action As Int, X As Float, Y As Float)
Dim ev As MouseEvent
ev.X = X
ev.Y = Y
If Action = DummyPanel.ACTION_DOWN Then
Pane1_MousePressed(ev)
Else if Action = DummyPanel.ACTION_MOVE Then
Pane1_MouseDragged(ev)
Else
Pane1_MouseReleased(ev)
End If
End Sub
#End If
6. In B4J and B4i the page or form can be resized at runtime. In most cases you will need to add a resize sub that handles this. As the original example didn't handle resizing I preferred not to add it here. The code in Main in B4i waits for the first page resize event and only then initializes the class.
The three projects are attached. BitmapCreator and Mandelbrot classes are identical and should be linked between the three projects.