Reputation: 195
newbitmap.SetPixel((int)clouds1[x].X, (int)clouds1[x].Y, Color.Red);
I set pixels in to a new bitmap with color red. In form1 i show the newbitmap in pictureBox3:
pictureBox3.Image = CloudEnteringAlert.newbitmap;
But the pixels are very small almost cant be see on the pictureBox3. How can i make the pixels bigger ?
Upvotes: 0
Views: 1681
Reputation: 112259
You can't, but you can draw a circle instead.
using(var g = Graphics.FromImage(newbitmap)) {
g.FillEllipse(Brushes.Red, (int)clouds1[x].X - radius,
(int)clouds1[x].Y - radius, 2 * radius, 2 * radius);
}
I created an extension method that simplifies drawing a circle (here with float coordinates):
public static void FillCircle(this Graphics g, Brush brush,
PointF center, float radius)
{
g.FillEllipse(brush, center.X - radius, center.Y - radius,
radius + radius, radius + radius);
}
If your clouds are PoinF
's you can call it like this:
using(var g = Graphics.FromImage(newbitmap)) {
g.FillCircle(Brushes.Red, clouds1[x], radius);
}
If not, adapt the extension method accordingly. Place such extension methods in a static class.
In order to get smooth circles you can use antialiasing. Set the SmoothingMode
of the Graphics
object to the desired value before drawing circles:
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
Upvotes: 1