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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. help needed pls

help needed pls

Scheduled Pinned Locked Moved .NET (Core and Framework)
graphicshelpquestion
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.
  • U Offline
    U Offline
    Umangj
    wrote on last edited by
    #1

    I am opening an image on a picturebox using: pictureBox1.Image = new Bitmap(openFileDialog1.FileName); then i am drawing some lines and curves on the picturebox using the event: private void pictureBox1_Paint(object sender, PaintEventArgs e) such that the painted lines and curves are drawn over the image opened on the picturebox. Now, I want to save the image containing the original image and the lines or curves drawn on the picturebox as one image. Please tell how do i do that........ Thank You Umang Jain

    D 1 Reply Last reply
    0
    • U Umangj

      I am opening an image on a picturebox using: pictureBox1.Image = new Bitmap(openFileDialog1.FileName); then i am drawing some lines and curves on the picturebox using the event: private void pictureBox1_Paint(object sender, PaintEventArgs e) such that the painted lines and curves are drawn over the image opened on the picturebox. Now, I want to save the image containing the original image and the lines or curves drawn on the picturebox as one image. Please tell how do i do that........ Thank You Umang Jain

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      Well, the first problem you have is that you're not drawing the lines on the image. You're drawing on the surface of the picturebox control. So, everything you see appears as though you're drawing on the image when you're not. You have to draw the lines on the bitmap you created, then you can save the changes back to the original files. Speaking of that, you have a second problem. When you created a Bitmap object using the overload that you did, the file gets locked for the life of that Bitmap object. This means you can't save any changes back to the original file. To get around this, you have to create a FileStream object, opening that image file, then create the Bitmap from that Stream, then closing the file. This will prevent the file from being locked so you can save the changes back to it.

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
           2006, 2007, 2008

      U 2 Replies Last reply
      0
      • D Dave Kreskowiak

        Well, the first problem you have is that you're not drawing the lines on the image. You're drawing on the surface of the picturebox control. So, everything you see appears as though you're drawing on the image when you're not. You have to draw the lines on the bitmap you created, then you can save the changes back to the original files. Speaking of that, you have a second problem. When you created a Bitmap object using the overload that you did, the file gets locked for the life of that Bitmap object. This means you can't save any changes back to the original file. To get around this, you have to create a FileStream object, opening that image file, then create the Bitmap from that Stream, then closing the file. This will prevent the file from being locked so you can save the changes back to it.

        A guide to posting questions on CodeProject[^]
        Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
             2006, 2007, 2008

        U Offline
        U Offline
        Umangj
        wrote on last edited by
        #3

        Thank you for replying but how do i paint it on the image... ???

        L 1 Reply Last reply
        0
        • U Umangj

          Thank you for replying but how do i paint it on the image... ???

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi, Graphics.FromImage() is what you want. :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          Fixturized forever. :confused:


          1 Reply Last reply
          0
          • D Dave Kreskowiak

            Well, the first problem you have is that you're not drawing the lines on the image. You're drawing on the surface of the picturebox control. So, everything you see appears as though you're drawing on the image when you're not. You have to draw the lines on the bitmap you created, then you can save the changes back to the original files. Speaking of that, you have a second problem. When you created a Bitmap object using the overload that you did, the file gets locked for the life of that Bitmap object. This means you can't save any changes back to the original file. To get around this, you have to create a FileStream object, opening that image file, then create the Bitmap from that Stream, then closing the file. This will prevent the file from being locked so you can save the changes back to it.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007, 2008

            U Offline
            U Offline
            Umangj
            wrote on last edited by
            #5

            Thank you so much... it worked... prob. solved

            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