Howto PictureBox to a bitmap
-
I am out of my element when doing graphics. Can someone give me hand.
private void draw() { if (end == 0) // The L_mousebutton is down { g = pictureBox1.CreateGraphics(); pictureBox1.Image = bitmap; } g.DrawRectangle(new Pen(border, (int)n_size.Value), startX, startY, endX - startX, endY - startY); if (end == 1) // The L_mousebutton is up { // here I want to put the edited image in the bitmap // the reverse of the above. bitmap = pictureBox1.Image; // Does not work //At this point I have the new image in pictureBox1 and I want //to put this new image into bitmap. Could someone show me a //code snippet. } }
TNX -
I am out of my element when doing graphics. Can someone give me hand.
private void draw() { if (end == 0) // The L_mousebutton is down { g = pictureBox1.CreateGraphics(); pictureBox1.Image = bitmap; } g.DrawRectangle(new Pen(border, (int)n_size.Value), startX, startY, endX - startX, endY - startY); if (end == 1) // The L_mousebutton is up { // here I want to put the edited image in the bitmap // the reverse of the above. bitmap = pictureBox1.Image; // Does not work //At this point I have the new image in pictureBox1 and I want //to put this new image into bitmap. Could someone show me a //code snippet. } }
TNXBitmap class has several constructs. Choose the one that meets your needs
#region signature my articles #endregion
-
Bitmap class has several constructs. Choose the one that meets your needs
#region signature my articles #endregion
-
MSDN has examples
#region signature my articles #endregion
-
I am out of my element when doing graphics. Can someone give me hand.
private void draw() { if (end == 0) // The L_mousebutton is down { g = pictureBox1.CreateGraphics(); pictureBox1.Image = bitmap; } g.DrawRectangle(new Pen(border, (int)n_size.Value), startX, startY, endX - startX, endY - startY); if (end == 1) // The L_mousebutton is up { // here I want to put the edited image in the bitmap // the reverse of the above. bitmap = pictureBox1.Image; // Does not work //At this point I have the new image in pictureBox1 and I want //to put this new image into bitmap. Could someone show me a //code snippet. } }
TNXelectriac wrote:
pictureBox1.Image = bitmap;
set pictureBox1.BackgroundImage = bitmap and Try to use this concept
Bitmap bm = new Bitmap(600, 600); Graphics g = Graphics.FromImage(bm); g.DrawRectangle(new Pen(border, (int)n_size.Value), startX, startY, endX - startX, endY - startY); pictureBox1.BackgroundImage = bm; bm.Save("bm.jpg", ImageFormat.Jpeg);
Hope this will help :)Best Regards ----------------- Abhijit Jana View My Latest Article :- SpyNet : Your Network Spy "Success is Journey it's not a destination"