Hello, I'm trying to create an app that lets me paste in a screen shot and paint over parts of it then copy the new image to the clipboard. I can get the image to copy and paste but I'm having trouble finding examples of painting freehand and saving the final image.
Thanks,
Jason
Loading
JasonPosted Jun 15, 2006, 12:40 PM
void PictureBox1Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
try
{
//e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
Graphics g = Graphics.FromImage(pictureBox1.Image);
g.SmoothingMode = SmoothingMode.HighQuality;
Pen drawingPen = new Pen(Color.White, 10);
//e.Graphics.DrawPath(drawingPen, mousePath);
g.DrawPath(drawingPen, mousePath);
}
catch
{}
}
It pasted just fine! Thanks guys.
JasonPosted Jun 15, 2006, 12:33 PM
void PictureBox1Paint(object sender, System.Windows.Forms.PaintEventArgs e)
{
try
{
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
Pen drawingPen = new Pen(Color.White, 10);
e.Graphics.DrawPath(drawingPen, mousePath);
}
catch
{}
}
void PictureBox1MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
mousePath.StartFigure();
}
}
void PictureBox1MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Left)
{
try
{
mousePath.AddLine(e.X,e.Y,e.X,e.Y);
}
catch
{
}
}
pictureBox1.Invalidate();
}
I need to put something on the MouseUp to merge them I think. Or I'm doing something wrong in the paint method.
Thanks
Mahesh ChandPosted Jun 15, 2006, 11:27 AM
Alternatively, You can also create Bitmap object on fly, load old image, add new objects and save as image.
Mahesh ChandPosted Jun 15, 2006, 11:23 AM
GDI+ & Graphics section of this site has many samples on what you are looking for.