how draw a single point?

ngr888

Member
Hi.
I'm new in this foro, and I can't speak english very well (sorry).
I need know how to draw a single point in a form. Like the old Qbasic: SETPOINT(x,y,color), or similar.
I'd read the graphics information but I do not see any way.
Thanks and regards.
ngr888.
 

sitajony

Active Member
Licensed User
Hi, you can use ImageLib.dll, in drawing a rectangle you can also draw a single point, there's maybe an better idea:
Salut, ty peux utiliser ImageLib.dll, en dessinant un rectangle tu peux aussi dessiner un point, il y'a peut être une meilleure idée:
B4X:
[FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]Sub [/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2]App_Start[/SIZE][/FONT]
[SIZE=2][FONT=Courier New]   Form1.Show[/FONT][/SIZE]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b]   Pen[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2].New1([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]cBlue[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b]   Drawer[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2].New1([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000][FONT=Courier New][SIZE=2][COLOR=#800000]"Form1"[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]False[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b]   Drawer[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2].DrawRectangle2([/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b][FONT=Courier New][SIZE=2][COLOR=#008b8b]Pen[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2].Value,[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]10[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]10[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2],[/SIZE][/FONT][/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080][FONT=Courier New][SIZE=2][COLOR=#800080]1[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT][FONT=Courier New][SIZE=2][FONT=Courier New][SIZE=2])[/SIZE][/FONT]
[/SIZE][/FONT][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff][FONT=Courier New][SIZE=2][COLOR=#0000ff]End Sub[/COLOR][/SIZE][/FONT]
[/COLOR][/SIZE][/FONT][/COLOR][/SIZE][/FONT]
 

corwin42

Expert
Licensed User
Longtime User
Take a look into the ImageLib library (I think this is provided even with the evaluation version of B4PPC?).

The BitMap object has a method SetPixel() to draw a single pixel.
 

ngr888

Member
Hello.
Thank you for the answers.
The idea of a rectangle or a line increasing the coordinates in a unit would be a solution.
In any case I believe that it is a lack the absence of a specific command to do it.
Some times I need to draw functions as:

y = f (x)

I will look also at the ImageLib library in search of the method SetPixel(...) indicated by corwin42

Regards.
 

ngr888

Member
Yes... Klaus. Sometimes I have used this way of planning functions in Visual Basic 6 (not visual .NET) joining with a straight line the current point with the following one and then updating the ancient coordinates with the new ones. It works well.
But sometimes I need to draw isolated points. For functions; or to represent clouds of points (is it said this way?), even random, in that then straight lines of regression are looked. Or...
My interests are didactic and experimental (very varied).
Thank you again.

De bonne après-midi à tous, spécialement pour sitajony.
 

sitajony

Active Member
Licensed User
Merci à toi aussi enfin bonne soirée maintenant lol...

Anyway: I noticed that with DrawLine it does't draw correctly a point, there're 2 points who is a line....
But you can also create an Image who show a point and you draw it on the Form...
Euh si tes français je te le traduit:
Tu peux sinon créer une image qui montre a point et tu le dessine ensuite sur la Form avec Form.DrawImage()...

Bonne chance
(Good Luck)
 

klaus

Expert
Licensed User
Longtime User
Here is a summary of how to draw a single pixel:

directly onto the form:
Form.Line(x,y,x+1,y+1,color,BF

with a Drawer object from the ImageLib or a DrawerEx object from the ImageLibEx onto the Form or onto a Bitmap:
Drawer.FillRectangle2(brush.Value,x,y,1,1)

with a Bitmap object from the ImageLib or a BitmapEx object from the ImageLibEx onto a bitmap:
Bitmap.SetPixel(x,y,color)

The ImageLibEx is available only for licensed users.

You can choose what function to use depending on what you want to draw, where and how.

Attached a small test program.

Best regards.
 

Attachments

  • DrawSinglePixel.sbp
    1.2 KB · Views: 208
Cookies are required to use this site. You must accept them to continue using the site. Learn more…