Results 1 to 4 of 4

Thread: Clip Image

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    england
    Posts
    598

    Clip Image

    Hi All,

    Is it possible to get the points of a image? for example a ellipse has 13 points in a graphics path, now if I had a image that was a ellipse how could I get 13 points from the image?

    is it possible?

    Thanks

    Loftty

  2. #2
    Arabic Poster ComputerJy's Avatar
    Join Date
    Nov 2005
    Location
    Happily misplaced
    Posts
    2,513

    Re: Clip Image

    You can scan the image point-by-point and put all colored points (not white) in an array

    But this only works for a special kind of images, where it only have one shape
    "I'm not normally a praying man, but if you're up there, save me... Superman!" - Homer Simpson
    My Blog

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    england
    Posts
    598

    Re: Clip Image

    Hi,

    This is how far I got as I need to create a graphics path from a image

    Code:
    OpenFileDialog op = new OpenFileDialog();
                op.ShowDialog();
    
                Bitmap b = new Bitmap(op.FileName);
                Bitmap bat = new Bitmap(Im, pictureBox1.Width, pictureBox1.Height);
                Image d = bat;
                Graphics g = Graphics.FromImage(d);
                g.SmoothingMode = SmoothingMode.AntiAlias;
    
                List<Point> pnts = new List<Point>();
                List<RectangleF> Rects = new List<RectangleF>();
                GraphicsPath gp = new GraphicsPath();
                int h = 0;
                for (int i = 0; i < b.Width; i++)
                {
    
                    for (int j = 0; j < b.Height; j++)
                    {
                        if (b.GetPixel(i, j) != Color.FromArgb(255, 255, 255, 255))
                        {
                            if (j <= h+1)
                            {
                                pnts.Add(new Point(i, j));
                            }
                            h = j;
                        }
                        
                    }
                }
    
                Point[] pts = new Point[pnts.Count];
                for (int i = 0; i < pnts.Count; i++)
                {
                    pts[i] = pnts[i];
                }
    
                gp.AddLines(pts);
                gp.CloseFigure();
                Brush bdd = new SolidBrush(Color.Red);
                g.FillPath(bdd, gp);
                g.DrawPath(new Pen(Color.Black), gp);
                
                pictureBox1.Refresh();
                pictureBox1.Image = d;
    Which is from the attached image, but for some reason it does not create the correct path.
    Why is this?

    Thanks

    Loftty
    Attached Images Attached Images  

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    england
    Posts
    598

    Re: Clip Image

    Hi,

    Is this possible to do then?

    Thanks

    Loftty

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width