Draw on bitmap

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:

Thank you.
 

Attachments

  • SetPixel1.zip
    4.2 KB · Views: 204

agraham

Expert
Licensed User
Longtime User
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?
 
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?
 

Attachments

  • setPixel2.zip
    10.7 KB · Views: 199

klaus

Expert
Licensed User
Longtime User
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.

Best regards.
 

Attachments

  • pixels_1.sbp
    2.7 KB · Views: 212
Hello Klaus. It works although I haven't yet bought the license and had to do
without ImageLibEx.. Thank you very much.

I'm creating kind of graphic editor for personal use, to make and edit sprites.
Next there will be :

Clr() = GetRGB(bmp1.GetPixel1(dotX + 1,dotY + 1))
Label1.text = clr.r & clr.g & clr.b

:sign0188:
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…