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. C#
  4. GDI+ problem (tough!)

GDI+ problem (tough!)

Scheduled Pinned Locked Moved C#
graphicshelpwinformsquestion
4 Posts 2 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.
  • R Offline
    R Offline
    r9
    wrote on last edited by
    #1

    I have this drawing: private System.Drawing.Graphics graphicsObj = null; private System.Drawing.Pen penBlackWidth1 = new System.Drawing.Pen(System.Drawing.Color.Black,1); private Point[] curvePoints = null; private SolidBrush lightGrayBrush = new SolidBrush(Color.LightGray); private Point point1; private Point point2; private Point point3; private Point point4; private SolidBrush blackBrush = new SolidBrush(Color.Black); ................................................... try { graphicsObj = e.Graphics; graphicsObj.DrawLine(penBlackWidth1, 45, 20, 175, 20); graphicsObj.DrawLine(penBlackWidth1, 45, 20, 45, 120); graphicsObj.DrawLine(penBlackWidth1, 175, 20, 175, 120); graphicsObj.DrawLine(penBlackWidth1, 45,120,90,160); graphicsObj.DrawLine(penBlackWidth1, 175, 120, 135, 160); graphicsObj.DrawLine(penBlackWidth1, 90, 160, 135, 160); graphicsObj.DrawLine(penBlackWidth1, 465, 335, 490, 335); graphicsObj.DrawLine(penBlackWidth1, 580, 335, 605, 335); graphicsObj.DrawLine(penBlackWidth1, 465, 335, 490, 335); graphicsObj.DrawLine(penBlackWidth1, 580, 335, 605, 335); graphicsObj.DrawLine(penBlackWidth1, 473, 345, 483, 345); graphicsObj.DrawLine(penBlackWidth1, 473, 345, 478, 335); graphicsObj.DrawLine(penBlackWidth1, 483, 345, 478, 335); graphicsObj.DrawLine(penBlackWidth1, 587, 345, 597, 345); graphicsObj.DrawLine(penBlackWidth1, 587, 345, 592, 335); graphicsObj.DrawLine(penBlackWidth1, 597, 345, 592, 335); point1 = new Point(592,335); point2 = new Point(597,345); point3 = new Point(587,345); point4 = new Point(592,335); curvePoints = new Point[] { point1,point2, point3, point4 }; graphicsObj.FillPolygon(blackBrush, curvePoints, FillMode.Alternate); point1 = new Point(478,335); point2 = new Point(483,345); point3 = new Point(473,345); point4 = new Point(478,335); curvePoints = new Point[] { point1,point2, point3, point4 }; graphicsObj.FillPolygon(blackBrush, curvePoints, FillMode.Alternate); } catch (Exception ex) { MessageBox.Show(ex.Message); } I want to fill the drawing with a color. From buttom to top. BUT the drawing must be filled accourding to a percent. Is 50%, then only 50% of the drawing must be filled with the color. Natural the fill must newer come outside the drawings edge. Any help? Thank

    R S 2 Replies Last reply
    0
    • R r9

      I have this drawing: private System.Drawing.Graphics graphicsObj = null; private System.Drawing.Pen penBlackWidth1 = new System.Drawing.Pen(System.Drawing.Color.Black,1); private Point[] curvePoints = null; private SolidBrush lightGrayBrush = new SolidBrush(Color.LightGray); private Point point1; private Point point2; private Point point3; private Point point4; private SolidBrush blackBrush = new SolidBrush(Color.Black); ................................................... try { graphicsObj = e.Graphics; graphicsObj.DrawLine(penBlackWidth1, 45, 20, 175, 20); graphicsObj.DrawLine(penBlackWidth1, 45, 20, 45, 120); graphicsObj.DrawLine(penBlackWidth1, 175, 20, 175, 120); graphicsObj.DrawLine(penBlackWidth1, 45,120,90,160); graphicsObj.DrawLine(penBlackWidth1, 175, 120, 135, 160); graphicsObj.DrawLine(penBlackWidth1, 90, 160, 135, 160); graphicsObj.DrawLine(penBlackWidth1, 465, 335, 490, 335); graphicsObj.DrawLine(penBlackWidth1, 580, 335, 605, 335); graphicsObj.DrawLine(penBlackWidth1, 465, 335, 490, 335); graphicsObj.DrawLine(penBlackWidth1, 580, 335, 605, 335); graphicsObj.DrawLine(penBlackWidth1, 473, 345, 483, 345); graphicsObj.DrawLine(penBlackWidth1, 473, 345, 478, 335); graphicsObj.DrawLine(penBlackWidth1, 483, 345, 478, 335); graphicsObj.DrawLine(penBlackWidth1, 587, 345, 597, 345); graphicsObj.DrawLine(penBlackWidth1, 587, 345, 592, 335); graphicsObj.DrawLine(penBlackWidth1, 597, 345, 592, 335); point1 = new Point(592,335); point2 = new Point(597,345); point3 = new Point(587,345); point4 = new Point(592,335); curvePoints = new Point[] { point1,point2, point3, point4 }; graphicsObj.FillPolygon(blackBrush, curvePoints, FillMode.Alternate); point1 = new Point(478,335); point2 = new Point(483,345); point3 = new Point(473,345); point4 = new Point(478,335); curvePoints = new Point[] { point1,point2, point3, point4 }; graphicsObj.FillPolygon(blackBrush, curvePoints, FillMode.Alternate); } catch (Exception ex) { MessageBox.Show(ex.Message); } I want to fill the drawing with a color. From buttom to top. BUT the drawing must be filled accourding to a percent. Is 50%, then only 50% of the drawing must be filled with the color. Natural the fill must newer come outside the drawings edge. Any help? Thank

      R Offline
      R Offline
      r9
      wrote on last edited by
      #2

      correction: if 50%, then only 50% of the drawing must be filled with the color.

      1 Reply Last reply
      0
      • R r9

        I have this drawing: private System.Drawing.Graphics graphicsObj = null; private System.Drawing.Pen penBlackWidth1 = new System.Drawing.Pen(System.Drawing.Color.Black,1); private Point[] curvePoints = null; private SolidBrush lightGrayBrush = new SolidBrush(Color.LightGray); private Point point1; private Point point2; private Point point3; private Point point4; private SolidBrush blackBrush = new SolidBrush(Color.Black); ................................................... try { graphicsObj = e.Graphics; graphicsObj.DrawLine(penBlackWidth1, 45, 20, 175, 20); graphicsObj.DrawLine(penBlackWidth1, 45, 20, 45, 120); graphicsObj.DrawLine(penBlackWidth1, 175, 20, 175, 120); graphicsObj.DrawLine(penBlackWidth1, 45,120,90,160); graphicsObj.DrawLine(penBlackWidth1, 175, 120, 135, 160); graphicsObj.DrawLine(penBlackWidth1, 90, 160, 135, 160); graphicsObj.DrawLine(penBlackWidth1, 465, 335, 490, 335); graphicsObj.DrawLine(penBlackWidth1, 580, 335, 605, 335); graphicsObj.DrawLine(penBlackWidth1, 465, 335, 490, 335); graphicsObj.DrawLine(penBlackWidth1, 580, 335, 605, 335); graphicsObj.DrawLine(penBlackWidth1, 473, 345, 483, 345); graphicsObj.DrawLine(penBlackWidth1, 473, 345, 478, 335); graphicsObj.DrawLine(penBlackWidth1, 483, 345, 478, 335); graphicsObj.DrawLine(penBlackWidth1, 587, 345, 597, 345); graphicsObj.DrawLine(penBlackWidth1, 587, 345, 592, 335); graphicsObj.DrawLine(penBlackWidth1, 597, 345, 592, 335); point1 = new Point(592,335); point2 = new Point(597,345); point3 = new Point(587,345); point4 = new Point(592,335); curvePoints = new Point[] { point1,point2, point3, point4 }; graphicsObj.FillPolygon(blackBrush, curvePoints, FillMode.Alternate); point1 = new Point(478,335); point2 = new Point(483,345); point3 = new Point(473,345); point4 = new Point(478,335); curvePoints = new Point[] { point1,point2, point3, point4 }; graphicsObj.FillPolygon(blackBrush, curvePoints, FillMode.Alternate); } catch (Exception ex) { MessageBox.Show(ex.Message); } I want to fill the drawing with a color. From buttom to top. BUT the drawing must be filled accourding to a percent. Is 50%, then only 50% of the drawing must be filled with the color. Natural the fill must newer come outside the drawings edge. Any help? Thank

        S Offline
        S Offline
        Shree
        wrote on last edited by
        #3

        Since you already have the coordinate points, create a region using these points and then use graphicsObj.ClipRgn() to set the clipping region. Then, you can draw a filled rectangle, without the fill color spilling out of the boundary. Not so tough!! :)

        R 1 Reply Last reply
        0
        • S Shree

          Since you already have the coordinate points, create a region using these points and then use graphicsObj.ClipRgn() to set the clipping region. Then, you can draw a filled rectangle, without the fill color spilling out of the boundary. Not so tough!! :)

          R Offline
          R Offline
          r9
          wrote on last edited by
          #4

          Hi Shree Can you give an example?

          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