Click here to Skip to main content
15,883,883 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have:
C#
GraphicsPath path = new GraphicsPath();

I wanna add a path by pixels, not by point.

Point Class doesn't match, because it adds minimum 2 pixels, not one.
C#
private void Draw(object sender, System.Windows.Forms.PaintEventArgs e)
{
    e.Graphics.DrawLine(Pens.Red, 10, 10, 10, 10); // Adds nothing.
    e.Graphics.DrawLine(Pens.Red, 10, 10, 11, 10); // Adds 2 pixels.
}
Posted
Updated 10-Oct-14 3:12am
v3
Comments
George Jonsson 10-Oct-14 7:54am    
A path is usually defined as a route through two or more points.
A one point path makes little sense.
BillWoodruff 10-Oct-14 8:08am    
How is it that a Point which is two co-ordinates pointing to some location in some region adds 2 pixels ?
George Jonsson 10-Oct-14 8:20am    
Good point. :)
Ziya1995 10-Oct-14 8:49am    
private void Draw(object sender, System.Windows.Forms.PaintEventArgs e)
{
e.Graphics.DrawLine(Pens.Red, 10, 10, 10, 10); // Adds nothing.
e.Graphics.DrawLine(Pens.Red, 10, 10, 11, 10); // Adds 2 pixels.
}

How to add 1 pixel? Not possible? Who knows?

1 solution

The Graphics class doesn't have a SetPixel method.

I think you need to look into Bitmap.SetPixel Method[^]

Or you can use GDI functions via Platform Invoke.
C# GetPixel and SetPixel[^]

It depends on your other requirements what is suitable for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900