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
Printable View
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
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
Hi,
This is how far I got as I need to create a graphics path from a image
Which is from the attached image, but for some reason it does not create the correct path.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;
Why is this?
Thanks
Loftty
Hi,
Is this possible to do then?
Thanks
Loftty