Click here to Skip to main content
15,889,706 members
Home / Discussions / C#
   

C#

 
GeneralRe: Plz, des'nt File Delete ,, Pin
Not Active18-May-10 2:41
mentorNot Active18-May-10 2:41 
GeneralRe: Plz, des'nt File Delete ,, Pin
William Winner18-May-10 7:29
William Winner18-May-10 7:29 
AnswerRe: Plz, des'nt File Delete ,, Pin
Seishin#18-May-10 4:39
Seishin#18-May-10 4:39 
QuestionCombobox SelectedValue Problem. Pin
Dotnetkanna17-May-10 23:30
Dotnetkanna17-May-10 23:30 
AnswerRe: Combobox SelectedValue Problem. Pin
Abhinav S18-May-10 0:34
Abhinav S18-May-10 0:34 
AnswerRe: Combobox SelectedValue Problem. Pin
Seishin#18-May-10 4:46
Seishin#18-May-10 4:46 
QuestionHow can save picturebox image using menustrip Pin
Nivas8217-May-10 21:00
Nivas8217-May-10 21:00 
AnswerRe: How can save picturebox image using menustrip Pin
William Winner18-May-10 8:00
William Winner18-May-10 8:00 
You're going to have some problems with the method you're using if you want to save it.

The best thing that I can suggest to do is to create an intermediate Bitmap to draw on and set your PictureBox1.Image value to that Bitmap. Then, you can save it pretty easily. For example:
C#
Rectangle rect = New Rectangle(0,0,0,0);
Bitmap myBitmap;

private void PictureBox_MouseDown(object sender, MouseEventArgs e)
{
  if (myBitmap == null)
  {
    myBitmap = New Bitmap(PictureBox1.Width, PictureBox1.Height, PictureBox1.CreateGraphics());
    PictureBox1.Image = myBitmap;
  }

  rect = New Rectangle(e.X, e.Y, 0, 0);
  PictureBox1.Invalidate();
}

private void PictureBox_MouseMove(object sender, MouseEventArgs e)
{
  if (e.Button == MouseButtons.Left)
  {
    rect = New Rectangle(rect.Left, rect.Top, e.X - rect.Left, e.Y - rect.Top);
    PictureBox1.Invalidate();
  }
}

private void PictureBox_Paint(object sender, PaintEventArgs e)
{
    if (myBitmap == null) { return; }

    using (Pen pen = New Pen(Color.Red, 2))
    {
      using (Graphics g = Graphics.FromImage(myBitmap))
      {
        g.Clear(Color.White);
        g.DrawRectangle(pen, rect);
      }
    }
}

private void saveToolStripMenuItem_Click(object sender, EventArgs e)
{
  if (myBitmap != null)
  {
    myBitmap.Save("D:\\Temp\\Bitmapsave.bmp", System.Drawing.Imaging.ImageFormat.Bmp);
  }
}


It's basically the same thing you've done, except instead of drawing on the bitmap instead of directly on the PaintBox.
GeneralRe: How can save picturebox image using menustrip Pin
Nivas8218-May-10 19:18
Nivas8218-May-10 19:18 
GeneralRe: How can save picturebox image using menustrip Pin
William Winner19-May-10 5:29
William Winner19-May-10 5:29 
GeneralRe: How can save picturebox image using menustrip Pin
Nivas8219-May-10 23:13
Nivas8219-May-10 23:13 
GeneralRe: How can save picturebox image using menustrip [modified] Pin
Nivas8220-May-10 20:54
Nivas8220-May-10 20:54 
QuestionWindows service Pin
Heinzzy17-May-10 18:47
Heinzzy17-May-10 18:47 
AnswerRe: Windows service Pin
N a v a n e e t h17-May-10 18:59
N a v a n e e t h17-May-10 18:59 
GeneralRe: Windows service Pin
Heinzzy17-May-10 19:46
Heinzzy17-May-10 19:46 
GeneralRe: Windows service Pin
Calla17-May-10 19:58
Calla17-May-10 19:58 
GeneralRe: Windows service Pin
Heinzzy17-May-10 20:26
Heinzzy17-May-10 20:26 
GeneralRe: Windows service Pin
Dave Kreskowiak18-May-10 5:18
mveDave Kreskowiak18-May-10 5:18 
AnswerRe: Windows service Pin
#realJSOP17-May-10 23:16
mve#realJSOP17-May-10 23:16 
AnswerRe: Windows service Pin
PIEBALDconsult18-May-10 4:47
mvePIEBALDconsult18-May-10 4:47 
AnswerRe: Windows service Pin
Heinzzy18-May-10 8:18
Heinzzy18-May-10 8:18 
Questionpartition clone with c# Pin
muteb17-May-10 17:13
muteb17-May-10 17:13 
AnswerRe: partition clone with c# Pin
Not Active17-May-10 18:07
mentorNot Active17-May-10 18:07 
AnswerRe: partition clone with c# Pin
PIEBALDconsult17-May-10 18:13
mvePIEBALDconsult17-May-10 18:13 
GeneralRe: partition clone with c# Pin
muteb17-May-10 19:10
muteb17-May-10 19:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.