public List <Color> getPathLine()
        {
            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            Point        sp, cp;
            List <Color> cl = new List <Color>();

            if (p == null)
            {
                return(null);
            }
            PathGeometry pg = p.Data as PathGeometry;

            if (pg == null)
            {
                return(null);
            }
            foreach (PathFigure pf in pg.Figures)
            {
                sp = DrawGraphic.getImagePosition(pf.StartPoint, TargetImage);

                foreach (LineSegment ls in pf.Segments)
                {
                    cp = DrawGraphic.getImagePosition(ls.Point, TargetImage);
                    List <Color> scl = pt.getLine(TargetImage.Source as WriteableBitmap, sp, cp);
                    foreach (Color cc in scl)
                    {
                        cl.Add(cc);
                    }
                    sp = new Point(cp.X, cp.Y);
                }
            }
            return(cl);
        }
Beispiel #2
0
        void img_PointerReleased(object sender, PointerRoutedEventArgs e)
        {
            si = Target.SelectLayer.getImage();
            if (si.Source == null)
            {
                return;
            }
            //double dx = Canvas.GetLeft(si) + Canvas.GetLeft(Target.SelectLayer);
            //double dy = Canvas.GetTop(si) + Canvas.GetTop(Target.SelectLayer);
            Point ep = e.GetCurrentPoint(si).Position;

            if (Math.Abs(sp.X - ep.X) < 1.1 && Math.Abs(sp.Y - ep.Y) < 1.1)
            {
                Point tp = DrawGraphic.getImagePosition(sp, si);
                Color c  = pt.GetPixel(si.Source as WriteableBitmap, Convert.ToInt32(tp.X), Convert.ToInt32(tp.Y));
                ShowColor(c);
            }
            else
            {
                int   sx, sy, w, h;
                Point isp = DrawGraphic.getImagePosition(sp, si);
                Point iep = DrawGraphic.getImagePosition(ep, si);
                if (isp.X < iep.X)
                {
                    sx = Convert.ToInt32(isp.X);
                    w  = Convert.ToInt32(iep.X - isp.X);
                }
                else
                {
                    sx = Convert.ToInt32(iep.X);
                    w  = Convert.ToInt32(isp.X - iep.X);
                }
                if (isp.Y < iep.Y)
                {
                    sy = Convert.ToInt32(isp.Y);
                    h  = Convert.ToInt32(iep.Y - isp.Y);
                }
                else
                {
                    sy = Convert.ToInt32(iep.Y);
                    h  = Convert.ToInt32(isp.Y - iep.Y);
                }
                WriteableBitmap sb;
                if (w == 0)
                {
                    w = 1;
                }
                if (h == 0)
                {
                    h = 1;
                }
                sb = pt.getImageArea(si.Source as WriteableBitmap, sx, sy, w, h);
                ColorImg.Source = sb;
                Color c = pt.getAverageColor(sb);
                ShowColor(c);
            }
            sp = DrawGraphic.getImagePosition(sp, si);
        }
        public List <Point> getImagePathPointList(List <Point> pl)
        {
            List <Point> ipl = new List <Point>();

            foreach (Point tp in pl)
            {
                Point ip = DrawGraphic.getImagePosition(tp, TargetImage);
                ipl.Add(ip);
            }
            return(ipl);
        }
Beispiel #4
0
        void c_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            if (!testHelper.TestChartNull())
            {
                return;
            }
            Canvas c = ChartPhoto.getDrawObjectCanvas();

            if (c.Children.Contains(hl))
            {
                c.Children.Remove(hl);
            }
            if (c.Children.Contains(vl))
            {
                c.Children.Remove(vl);
            }
            buttonInterActiveTest.Foreground = new SolidColorBrush(Colors.Blue);
            c.PointerMoved   -= new PointerEventHandler(c_PointerMoved);
            c.PointerPressed -= c_PointerPressed;

            DrawGraphic dg = new DrawGraphic();
            Point       tp = e.GetCurrentPoint(ChartPhoto).Position;
            Point       ip = DrawGraphic.getImagePosition(tp, ChartPhoto.getImage());

            Color cc = testHelper.CurrentChart.GetPixel(ChartPhoto.getPhoto(), (int)ip.X, (int)ip.Y);

            //TempPhoto =new WriteableBitmap( ChartPhoto.getPhoto());//复制一份保留
            try
            {
                WriteableBitmap oi;
                int             n = testHelper.CurrentChart.getFloodBrightEdge(ChartPhoto.getPhoto(), out oi, ip, lynxUpDown2.IntValue);
                IsNeedSave = false;
                ChartPhoto.setPhoto(oi);
                textPixNum.Text = n.ToString();
            }
            catch (Exception xe)        //未知的异常
            {
                if (xe is LFCException) //已经是系统约定的错误类型,直接往上抛
                {
                    SilverlightLFC.common.Environment.ShowMessage(xe.Message);
                }
                else
                {
                    SilverlightLFC.common.Environment.ShowMessage("计算亮度变化错误");
                }
            }
        }
Beispiel #5
0
        void c_PointerPressed(object sender, Windows.UI.Xaml.Input.PointerRoutedEventArgs e)
        {
            Canvas c = sender as Canvas;

            if (c.Children.Contains(hl))
            {
                c.Children.Remove(hl);
            }
            if (c.Children.Contains(vl))
            {
                c.Children.Remove(vl);
            }
            CustomButtonBrush = DeactiveBrush;
            c.PointerMoved   -= c_PointerMoved;
            c.PointerPressed -= c_PointerPressed;
            if (CurrentPhoto == null)
            {
                return;
            }
            DrawGraphic dg = new DrawGraphic();
            Point       tp = e.GetCurrentPoint(c).Position;
            Point       ip = DrawGraphic.getImagePosition(tp, currentPhotoControl.getImage());

            Color cc = TestChart.GetPixel(currentPhotoControl.getPhoto(), (int)ip.X, (int)ip.Y);

            //TempPhoto =new WriteableBitmap( ChartPhoto.getPhoto());//复制一份保留
            try
            {
                WriteableBitmap oi;
                CustomSelectPointSimularPixelNum = TestChart.getFloodBrightEdge(currentPhotoControl.getPhoto(), out oi, ip, BrightGradeDistance);
                //IsNeedSave = false;
                currentPhotoControl.setPhoto(oi);
            }
            catch (Exception xe)        //未知的异常
            {
                if (xe is LFCException) //已经是系统约定的错误类型,直接往上抛
                {
                    SilverlightLFC.common.Environment.ShowMessage(xe.Message);
                }
                else
                {
                    SilverlightLFC.common.Environment.ShowMessage("Calculate error:" + xe.Message);
                    //MessageBox.Show("计算亮度变化错误");
                }
            }
        }
        public void DrawAreaBrightness()
        {
            if (r == null)
            {
                return;
            }
            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            DrawGraphic             dg = new DrawGraphic(DrawCanvas);
            WriteableBitmap         sb = TargetImage.Source as WriteableBitmap;
            Point           isp        = DrawGraphic.getImagePosition(sp, TargetImage);
            double          iw         = DrawGraphic.getImageDistance(r.Width, TargetImage);
            double          ih         = DrawGraphic.getImageDistance(r.Height, TargetImage);
            WriteableBitmap cb         = pt.getImageArea(sb, (int)isp.X, (int)isp.Y, (int)iw, (int)ih);

            List <int> tl = pt.getBrightPixNum(cb);

            dg.ForeColor = Colors.Blue;
            dg.DrawBrightPixNumHistogram(tl);
            textBlockValue.Text = (iw * ih).ToString();
        }
        public WriteableBitmap getSelectArea()
        {
            if (Photo == null)
            {
                return(null);
            }
            if (!EditLayer.Children.Contains(selectArea))
            {
                return(null);
            }

            DrawGraphic dg  = new DrawGraphic();
            Point       isp = DrawGraphic.getImagePosition(new Point(Canvas.GetLeft(selectArea), Canvas.GetTop(selectArea)), getImage());

            Point iep = DrawGraphic.getImagePosition(new Point(Canvas.GetLeft(selectArea) + selectArea.Width, Canvas.GetTop(selectArea) + selectArea.Height), getImage());

            DCTestLibrary.PhotoTest pht = new DCTestLibrary.PhotoTest();
            WriteableBitmap         sb  = pht.getImageArea(Photo, (int)isp.X, (int)isp.Y, (int)(iep.X - isp.X), (int)(iep.Y - isp.Y));

            return(sb);
        }
        //public void DeActiveDrawPath()
        //{
        //    if (Target == null) { return; }

        //    if (selectPath == null) { return; }

        //    Canvas drawCanvas = Target.getCanvas();
        //    if (drawCanvas.Children.Contains(selectPath)) { drawCanvas.Children.Remove(selectPath); }
        //    selectPath = null;
        //}

        //public void DeActiveDrawLine()
        //{
        //    if (Target == null) { return; }

        //    if (selectPath == null) { return; }

        //    Canvas drawCanvas = Target.getCanvas();
        //    if (drawCanvas.Children.Contains(selectLine)) { drawCanvas.Children.Remove(selectLine); }
        //    selectLine = null;
        //}

        //public void DeActiveDrawArea()
        //{
        //    if (Target == null) { return; }

        //    if (selectPath == null) { return; }

        //    Canvas drawCanvas = Target.getCanvas();
        //    if (drawCanvas.Children.Contains(selectRec)) { drawCanvas.Children.Remove(selectRec); }
        //    selectRec = null;
        //}


        public List <Color> getPathLine()
        {
            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            Point        sp, cp;
            List <Color> cl = new List <Color>();

            if (selectPath == null)
            {
                return(null);
            }
            if (selectPath.Points.Count == 0)
            {
                return(null);
            }
            sp = DrawGraphic.getImagePosition(selectPath.Points[0], TargetImage);
            for (int i = 1; i < selectPath.Points.Count; i++)
            {
                cp = DrawGraphic.getImagePosition(selectPath.Points[i], TargetImage);
                List <Color> scl = pt.getLine(TargetImage.Source as WriteableBitmap, sp, cp);
                foreach (Color cc in scl)
                {
                    cl.Add(cc);
                }
                sp = cp;
            }
            //PathGeometry pg = selectPath.Data as PathGeometry;
            //if (pg == null) { return null; }
            //foreach (PathFigure pf in pg.Figures)
            //{
            //    sp = DrawGraphic.getImagePosition(pf.StartPoint, TargetImage);

            //    foreach (LineSegment ls in pf.Segments)
            //    {
            //        cp = DrawGraphic.getImagePosition(ls.Point, TargetImage);

            //        sp = new Point(cp.X, cp.Y);
            //    }
            //}
            return(cl);
        }
        public void DrawAreaBrightness()
        {
            if (selectRec == null)
            {
                return;
            }
            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            DrawGraphic             dg = new DrawGraphic(DrawCanvas);
            WriteableBitmap         sb = TargetImage.Source as WriteableBitmap;
            Point           isp        = DrawGraphic.getImagePosition(sp, TargetImage);
            Point           iep        = DrawGraphic.getImagePosition(ep, TargetImage);
            double          iw         = DrawGraphic.getImageDistance(Math.Abs(iep.X - isp.X), TargetImage);
            double          ih         = DrawGraphic.getImageDistance(Math.Abs(iep.Y - isp.Y), TargetImage);
            WriteableBitmap cb         = pt.getImageArea(sb, (int)isp.X, (int)isp.Y, (int)iw, (int)ih);

            List <int> tl = pt.getBrightPixNum(cb);

            dg.ForeColor = Colors.Blue;
            dg.DrawBrightPixNumHistogram(tl);
            textPointCountValue.Text = (iw * ih).ToString();
            List <Color> cl = pt.getImageColorList(cb);

            ShowBrightInfor(cl);
        }