Hello.
I have spent 3 hours trying to draw a dot on a bitmap , so far in vain :sign0148:
Can somebody tell me how to draw bitmap2 on bitmap1? Or better set pixel
on bitmap1(bitmap1.SetPixel(x,y,cred))? I guess the latter is possible as GetPixel does work.
:BangHead:
Bmp2 is not being displayed anywhere! You can draw on Bmp1 then draw it on the Form.
B4X:
Sub App_Start
Form1.Show
bmp1.New2(100,100)
Drawer.New1("form1",False)
For i = 0 To 99
bmp1.SetPixel(i, i, cRed)
Next
rectsrc.New1(0,0,bmp1.Width,bmp1.Height)
rectdest.New1(0,0,bmp1.Width,bmp1.Height)
Drawer.DrawImage1(bmp1.Value,rectsrc.Value,rectdest.Value,False)
End Sub
Hello Andrew. Thanks a lot, it works fine in Sub App_Start
Well, I don't understand why doesn't it work in Sub Button_Click.
My actual intention was to get a dot moving at a button_click event:
Sub Globals
Dim dotX,dotY
End Sub
................
...............
Sub Button1_Click
dotX = 1 : dotY = 1
bitmap1.SetPixel(dotX,dotY,cRed)
dotX = dotX + 1
End Sub
I have tried different ways but SetPixel doesn't seem to work in Sub Button_Click.
:sign0137:
Any idea?
You are drawing on the bitmap but the bitmap is not being displayed anywhere. To see it you need to draw the bitmap onto a form, or assign it to a Form or an Image control Image property.
The bitmap is being dispayed nicely.
What I'm trying to do is get the red point moving at Button_Click event. I have
been doing it the entire evening :sign0161:
Can anybody give me a solution?
Here you are.
In the attached program you'll find different possibilities.
- Draw Form draws the point directly onto the form's forelayer
- Draw draws the point onto the form's forelayer with a Drawer object
- Draw Bmp draws the point onto a bitmap and copies the bitmap onto the form, in this case the previous point is not erased.
Your bitmap is very small, I streched it to fit into the form.