1. You should use the Canvas object to copy a rectangle from one bitmap to another.
2. Activity_Touch event.
Do the following steps:
1. Write Sub followed by space.
2. Press Tab.
3. Choose Activity - Touch
shouldn't the dest rect be defined with reference to the target (in this case - the activity), other wise how to draw on another bitmap ?
edit: found the answer to the drawing on bitmap - by the canvas initialize2, but the error is still unclear.
edit : found that one too - the canvas wasn't initialized. now i'm happy.
File doesn't include anything on writing text to a file, after opening it, only reading, and only the whole file. How do I read a line, and write a line ?
initializing a canvas on a view (not activity) raises an error - "width and height must be >0". I tried both imageview and a button, defined by the designer or added by code, and the size is 580x580.
Can you check please ?
Thank you.
now this - how do I initialize a stream ? I declared the object but there is no method for initializing it.
B4X:
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim tb1 As EditText
Dim out As EditText
Dim doit As Button
Dim tr As TextReader
Dim input As InputStream
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("flay")
'input.initialize ?????????????????/
tb1.Text = input.IsInitialized ' shows false of course
tr.Initialize(input)
File.OpenInput(File.DirDefaultExternal,"central.txt")
End Sub
Dim TextReader1 As TextReader
TextReader1.Initialize(File.OpenInput(File.DirInternal, "central.txt"))
The following code is also fine:
B4X:
Dim TextReader1 As TextReader
Dim InputStream1 As InputStream
InputStream1 = File.OpenInput(File.DirInternal, "central.txt")
TextReader1.Initialize(InputStream1)
Note that you can also declare the variables locally (if not needed globally).
Dim bmp As Bitmap
Dim img As ImageView
Dim cnvs As Canvas
Dim board As Canvas
Dim srect As Rect
Dim drect As Rect
Dim trect As Rect
Dim angle,cx,cy,px,py,x0,y0,a,b As Int
Dim z As Float
Dim zoomval As EditText
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("layout1")
a = 2
b = 6
cnvs.Initialize(activity)
img.Initialize(img)
board.Initialize(img)