cheezy
Member
Saving a Graphic as BMP
Hi:
Ive been working on this problem for several days now and Im really confused; what Im trying to do is pop up a form with a place for a person to make his/her signature, and save that to a bmp file on a button click. Heres what Ive got so far:
I have this (blank) pictureBox that Im using as the writing surface, and getting a script-signature I do the following:
This works well enough; I get a signature-looking thing on my form but I havent figured out a way to save this image onto my hard drive. Anybody have help? I researched this on Extreme.net and the closest advice is reasonable (to convert the graphics to a bitmap image and then save the bitmap) but I cannot figure out the code for this.
Thanks!
Hi:
Ive been working on this problem for several days now and Im really confused; what Im trying to do is pop up a form with a place for a person to make his/her signature, and save that to a bmp file on a button click. Heres what Ive got so far:
I have this (blank) pictureBox that Im using as the writing surface, and getting a script-signature I do the following:
C#:
private void pictureBox2_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(ShouldPaint)
{
if(x0 !=0 &&y0 != 0 )
{
Graphics g = pictureBox2.CreateGraphics();
Pen blackPen = new Pen(Color.Black, 2);
Point startPoint = new Point(x0,y0);
Point endPoint = new Point(e.X,e.Y);
g.DrawLine(blackPen,startPoint,endPoint);
g.Dispose();
}
x0 = e.X;
y0 = e.Y;
}
}
private void pictureBox2_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
ShouldPaint = true;
}
private void pictureBox2_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e)
{
ShouldPaint = false;
x0 = 0;
y0 = 0;
}
This works well enough; I get a signature-looking thing on my form but I havent figured out a way to save this image onto my hard drive. Anybody have help? I researched this on Extreme.net and the closest advice is reasonable (to convert the graphics to a bitmap image and then save the bitmap) but I cannot figure out the code for this.
Thanks!
Last edited by a moderator: