Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Howto PictureBox to a bitmap

Howto PictureBox to a bitmap

Scheduled Pinned Locked Moved C#
graphics
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    electriac
    wrote on last edited by
    #1

    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

    G A 2 Replies Last reply
    0
    • E electriac

      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

      G Offline
      G Offline
      Giorgi Dalakishvili
      wrote on last edited by
      #2

      Bitmap class has several constructs. Choose the one that meets your needs

      #region signature my articles #endregion

      E 1 Reply Last reply
      0
      • G Giorgi Dalakishvili

        Bitmap class has several constructs. Choose the one that meets your needs

        #region signature my articles #endregion

        E Offline
        E Offline
        electriac
        wrote on last edited by
        #3

        A snippet of code would be helpful.

        G 1 Reply Last reply
        0
        • E electriac

          A snippet of code would be helpful.

          G Offline
          G Offline
          Giorgi Dalakishvili
          wrote on last edited by
          #4

          MSDN has examples

          #region signature my articles #endregion

          1 Reply Last reply
          0
          • E electriac

            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

            A Offline
            A Offline
            Abhijit Jana
            wrote on last edited by
            #5

            electriac 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"

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups