Example #1
0
        public List <Dictionary <Point, Color> > measureLine(Bands lines)
        {
            arrayOfPoints.Clear();
            Lines.Add(new Line(startPoint, endPoint));

            List <Dictionary <Point, Color> > ret = new List <Dictionary <Point, Color> >();

            Bitmap bmp = new Bitmap(this.Bounds.Width, this.Bounds.Height);

            using (Graphics g = Graphics.FromImage(bmp))
            {
                g.DrawImage(BgImage, new Rectangle(new Point(0, 0), new Size(Bounds.Width, Bounds.Height)));
            }

            foreach (Line l in Lines)
            {
                Point p1 = l.p1;
                Point p2 = l.p2;

                Dictionary <Point, Color> tmp = new Dictionary <Point, Color>();
                List <Point> pointArr         = new List <Point>();

                if (p1 != Point.Empty && p2 != Point.Empty)
                {
                    ih = new imageHandler(bgImage, p1, p2, lines);
                    pointArr.AddRange(ih.getPixelsAlongVector());
                    arrayOfPoints.AddRange(pointArr);
                    arrayOfColors.Clear();



                    Color tmpColor = Color.White;

                    foreach (Point p in pointArr)
                    {
                        try
                        {
                            tmpColor = bmp.GetPixel(p.X, p.Y);
                            try
                            {
                                if (!tmp.Keys.Contains(p))
                                {
                                    tmp.Add(p, tmpColor);
                                }
                            }
                            catch (Exception ex)
                            {
                                Console.WriteLine(ex.ToString());
                            }
                            arrayOfColors.Add(tmpColor);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.ToString());
                        }
                    }
                }

                ret.Add(tmp);
            }

            Invalidate();
            return(ret);
        }
Example #2
0
 public void InitializeIh()
 {
     ih = new imageHandler(bgImage, startPoint, endPoint, Bands.auto);
 }