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. How to mark part of the image that appear on my application ?

How to mark part of the image that appear on my application ?

Scheduled Pinned Locked Moved C#
questioncsharpwpftutorial
5 Posts 4 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.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    Hi, I'm using picturebox to show some images that my application hold. I want to mark with some square part of my image ( mark in the code ). How can i do it ? Thanks. P.S I'm using simple winform (not WPF)

    R I 2 Replies Last reply
    0
    • L Lost User

      Hi, I'm using picturebox to show some images that my application hold. I want to mark with some square part of my image ( mark in the code ). How can i do it ? Thanks. P.S I'm using simple winform (not WPF)

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      You'll need to create a watermarked version of the Image before setting it into the PictureBox control. /ravi

      My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

      1 Reply Last reply
      0
      • L Lost User

        Hi, I'm using picturebox to show some images that my application hold. I want to mark with some square part of my image ( mark in the code ). How can i do it ? Thanks. P.S I'm using simple winform (not WPF)

        I Offline
        I Offline
        ignrod
        wrote on last edited by
        #3

        Maybe you want something like the following:

        Graphics g = Graphics.FromImage(pb.Image); // Assume pb is your PictureBox
        g.DrawRectangle(Pens.Red, pbleft, pbtop, pbwidth, pbheight); // Draw red rectangle in your image.
        g.Dispose();

        This will draw a red rectangle in your image. Is that what you want?

        L 1 Reply Last reply
        0
        • I ignrod

          Maybe you want something like the following:

          Graphics g = Graphics.FromImage(pb.Image); // Assume pb is your PictureBox
          g.DrawRectangle(Pens.Red, pbleft, pbtop, pbwidth, pbheight); // Draw red rectangle in your image.
          g.Dispose();

          This will draw a red rectangle in your image. Is that what you want?

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

          I don't think the PictureBox will even be aware you did that. You would have to reload the image or otherwise signal it about the change. BTW: I think PictureBoxes are crap anyway, one should not even try and do such complex :-D things to them. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

          I 1 Reply Last reply
          0
          • L Luc Pattyn

            I don't think the PictureBox will even be aware you did that. You would have to reload the image or otherwise signal it about the change. BTW: I think PictureBoxes are crap anyway, one should not even try and do such complex :-D things to them. :)

            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

            Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

            I Offline
            I Offline
            ignrod
            wrote on last edited by
            #5

            That's probably true. In that case

            Image im = pb.Image; // Assume pb is your PictureBox
            Graphics g = Graphics.FromImage(im);
            g.DrawRectangle(Pens.Red, pbleft, pbtop, pbwidth, pbheight); // Draw red rectangle in your image.
            g.Dispose();
            pb.Image = im;

            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