i have a picturebox, after loading image on that i'm drwaing some lines and rectangle using drawing objects, also adding some controls at runtime.
but during printing or saving dat image it saves only dat image without any lines or rectangle...
pl help how to save with drawing part
my load image code is like:
private void loadImageToolStripMenuItem_Click(object sender, EventArgs e)
{
try
{
OpenFileDialog open = new OpenFileDialog();
open.Filter = "Image Files(*.jpg; *.jpeg; *.gif; *.bmp)|*.jpg; *.jpeg; *.gif; *.bmp";
if (open.ShowDialog() == DialogResult.OK)
{
pictureBox1.Image = new Bitmap(open.FileName);
trackBar1.Value = pictureBox1.Height;
trackBar2.Value = pictureBox1.Height;
}
}
catch (ApplicationException ex)
{
MessageBox.Show(ex.Message.ToString());
}
trackBar1.Enabled = true;
trackBar2.Enabled = true;
pictureBox1.Enabled = true;
lineToolStripMenuItem.Enabled = false;
}
private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
{
Graphics g = null;
g = Graphics.FromImage(pictureBox1.Image);
g = pictureBox1.CreateGraphics();
g.DrawLine(Pens.Red, 0, Convert.ToInt32(trackBar1.Maximum) - trackBar1.Value, Convert.ToInt32(pictureBox1.Width), Convert.ToInt32(trackBar1.Maximum) - trackBar1.Value);
g.DrawLine(Pens.Blue, 0, Convert.ToInt32(trackBar2.Maximum) - trackBar2.Value, Convert.ToInt32(pictureBox1.Width), Convert.ToInt32(trackBar2.Maximum) - trackBar2.Value);
g.Dispose();
mouseMovePt = e.Location;
}
private void saveImageToolStripMenuItem_Click_1(object sender, EventArgs e)
{
SaveFileDialog savefile = new SaveFileDialog();
savefile.DefaultExt = "jpeg";
savefile.Filter = "All files*.*|*.*";
if (savefile.ShowDialog() == DialogResult.OK)
{
int width = pictureBox1.Width;
int height = pictureBox1.Height;
Bitmap bitmap = new Bitmap(width, height);
Rectangle rc = new Rectangle(0, 0, width, height);
pictureBox1.DrawToBitmap(bitmap, rc);
bitmap.Save(savefile.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
}
}
thnxxxxxxx