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 draw border on round image png?

how draw border on round image png?

Scheduled Pinned Locked Moved C#
graphicshelpquestion
7 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.
  • L Offline
    L Offline
    Le rner
    wrote on last edited by
    #1

    hi all, can anybody help me to draw a thick border around round png.

    Bitmap bmp = new Bitmap(@"C:\Users\Ali\Desktop\1.png");
    int w = bmp.Width;
    int h = bmp.Height;
    Lst_Data lastpointcolor = new Lst_Data() ;
    for (int y = 0; y < h; y++)
    {
    for (int x = 0; x < w; x++)
    {
    Color c = bmp.GetPixel(x, y);
    if (c.A != Color.Transparent.A)
    {
    if (lastpointcolor.color.A == Color.Transparent.A)
    {
    bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
    }
    }
    lastpointcolor = new Lst_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
    }
    }

            for (int y = h-1; y > 0; y--)
            {
                for (int x = w-1; x > 0; x--)
                {
                    Color c = bmp.GetPixel(x, y);
                    if (c.A != Color.Transparent.A)
                    {
                        if (lastpointcolor.color.A == Color.Transparent.A)
                        {
                            bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
                        }
                    }
                    lastpointcolor = new Lst\_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
                }
            }
            pictureBox1.Image = bmp;
        }
    

    public struct Lst_Data
    {
    public Point point;
    public Color color;
    }

    thanks in advance.

    P L 2 Replies Last reply
    0
    • L Le rner

      hi all, can anybody help me to draw a thick border around round png.

      Bitmap bmp = new Bitmap(@"C:\Users\Ali\Desktop\1.png");
      int w = bmp.Width;
      int h = bmp.Height;
      Lst_Data lastpointcolor = new Lst_Data() ;
      for (int y = 0; y < h; y++)
      {
      for (int x = 0; x < w; x++)
      {
      Color c = bmp.GetPixel(x, y);
      if (c.A != Color.Transparent.A)
      {
      if (lastpointcolor.color.A == Color.Transparent.A)
      {
      bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
      }
      }
      lastpointcolor = new Lst_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
      }
      }

              for (int y = h-1; y > 0; y--)
              {
                  for (int x = w-1; x > 0; x--)
                  {
                      Color c = bmp.GetPixel(x, y);
                      if (c.A != Color.Transparent.A)
                      {
                          if (lastpointcolor.color.A == Color.Transparent.A)
                          {
                              bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
                          }
                      }
                      lastpointcolor = new Lst\_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
                  }
              }
              pictureBox1.Image = bmp;
          }
      

      public struct Lst_Data
      {
      public Point point;
      public Color color;
      }

      thanks in advance.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      What technology are you using? WinForms? WPF? Other?

      Advanced TypeScript Programming Projects

      L 1 Reply Last reply
      0
      • P Pete OHanlon

        What technology are you using? WinForms? WPF? Other?

        Advanced TypeScript Programming Projects

        L Offline
        L Offline
        Le rner
        wrote on last edited by
        #3

        winform i m taking help from this article https://stackoverflow.com/questions/15858002/drawing-a-border-on-an-image[^] i also want to set different width of border.

        L 1 Reply Last reply
        0
        • L Le rner

          winform i m taking help from this article https://stackoverflow.com/questions/15858002/drawing-a-border-on-an-image[^] i also want to set different width of border.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          Le@rner wrote:

          i m taking help from this article

          Then you should ask the person who wrote the article. As it stands you have not provided any useful information for people to help you.

          L 1 Reply Last reply
          0
          • L Lost User

            Le@rner wrote:

            i m taking help from this article

            Then you should ask the person who wrote the article. As it stands you have not provided any useful information for people to help you.

            L Offline
            L Offline
            Le rner
            wrote on last edited by
            #5

            Bitmap bmp = new Bitmap(@"C:\Users\Ali\Desktop\1.png");
            int w = bmp.Width;
            int h = bmp.Height;
            Lst_Data lastpointcolor = new Lst_Data() ;
            for (int y = 0; y < h; y++)
            {
            for (int x = 0; x < w; x++)
            {
            Color c = bmp.GetPixel(x, y);
            if (c.A != Color.Transparent.A)
            {
            if (lastpointcolor.color.A == Color.Transparent.A)
            {
            bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
            }
            }
            lastpointcolor = new Lst_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
            }
            }

                    for (int y = h-1; y > 0; y--)
                    {
                        for (int x = w-1; x > 0; x--)
                        {
                            Color c = bmp.GetPixel(x, y);
                            if (c.A != Color.Transparent.A)
                            {
                                if (lastpointcolor.color.A == Color.Transparent.A)
                                {
                                    bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
                                }
                            }
                            lastpointcolor = new Lst\_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
                        }
                    }
                    pictureBox1.Image = bmp;
                }
            

            public struct Lst_Data
            {
            public Point point;
            public Color color;
            }

            can anybody help to draw more thick border around the image

            L 1 Reply Last reply
            0
            • L Le rner

              Bitmap bmp = new Bitmap(@"C:\Users\Ali\Desktop\1.png");
              int w = bmp.Width;
              int h = bmp.Height;
              Lst_Data lastpointcolor = new Lst_Data() ;
              for (int y = 0; y < h; y++)
              {
              for (int x = 0; x < w; x++)
              {
              Color c = bmp.GetPixel(x, y);
              if (c.A != Color.Transparent.A)
              {
              if (lastpointcolor.color.A == Color.Transparent.A)
              {
              bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
              }
              }
              lastpointcolor = new Lst_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
              }
              }

                      for (int y = h-1; y > 0; y--)
                      {
                          for (int x = w-1; x > 0; x--)
                          {
                              Color c = bmp.GetPixel(x, y);
                              if (c.A != Color.Transparent.A)
                              {
                                  if (lastpointcolor.color.A == Color.Transparent.A)
                                  {
                                      bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
                                  }
                              }
                              lastpointcolor = new Lst\_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
                          }
                      }
                      pictureBox1.Image = bmp;
                  }
              

              public struct Lst_Data
              {
              public Point point;
              public Color color;
              }

              can anybody help to draw more thick border around the image

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              You should have added that to your original question, and add an explanation of what is wrong.

              1 Reply Last reply
              0
              • L Le rner

                hi all, can anybody help me to draw a thick border around round png.

                Bitmap bmp = new Bitmap(@"C:\Users\Ali\Desktop\1.png");
                int w = bmp.Width;
                int h = bmp.Height;
                Lst_Data lastpointcolor = new Lst_Data() ;
                for (int y = 0; y < h; y++)
                {
                for (int x = 0; x < w; x++)
                {
                Color c = bmp.GetPixel(x, y);
                if (c.A != Color.Transparent.A)
                {
                if (lastpointcolor.color.A == Color.Transparent.A)
                {
                bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
                }
                }
                lastpointcolor = new Lst_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
                }
                }

                        for (int y = h-1; y > 0; y--)
                        {
                            for (int x = w-1; x > 0; x--)
                            {
                                Color c = bmp.GetPixel(x, y);
                                if (c.A != Color.Transparent.A)
                                {
                                    if (lastpointcolor.color.A == Color.Transparent.A)
                                    {
                                        bmp.SetPixel(lastpointcolor.point.X, lastpointcolor.point.Y, Color.Red);
                                    }
                                }
                                lastpointcolor = new Lst\_Data() { point = new Point(x, y), color = bmp.GetPixel(x, y) };
                            }
                        }
                        pictureBox1.Image = bmp;
                    }
                

                public struct Lst_Data
                {
                public Point point;
                public Color color;
                }

                thanks in advance.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                You draw an ellipse and place it "over" the image where the border would be. (Images aren't "round"; they're rectangles with transparent backgrounds that simulate a particular shape). [Graphics.DrawEllipse Method (System.Drawing) | Microsoft Docs](https://docs.microsoft.com/en-us/dotnet/api/system.drawing.graphics.drawellipse?view=dotnet-plat-ext-6.0)

                "Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I

                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