sourcez 0 Junior Poster in Training

Here's what I'm trying to do:

I have a bitmap I'm displaying, I want to be able to draw onto it using the pen tool.

The current code I have for this on mousemove is:

if (e.Button == MouseButtons.Left)
{
Bitmap pg = new Bitmap(Image);
Graphics go = Graphics.FromImage(pg);
Pen myPen = new Pen(Color.Black, 2);
go.DrawLine(myPen, OldX, OldY, e.X, e.Y);
OldX = e.X;
OldY = e.Y;
Image = pg;
}

How can I do the same thing in onPaint? So when the mouse is down draw a pen (and lines) just like the pen in paint onto the bitmap?

Thanks for any help, if possible examples :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.