예제 #1
0
        public void ProcessGreen(int n)
        {
            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            WriteableBitmap         b  = p.getPhoto();

            p.setPhoto(pt.GreenBitmap(b, n));
        }
예제 #2
0
        public void ProcessBright(int n)
        {
            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            WriteableBitmap         b  = p.getPhoto();

            p.setPhoto(pt.BrightnessBitmap(b, n));
        }
예제 #3
0
        public void ProcessInvert()
        {
            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            WriteableBitmap         b  = p.getPhoto();

            p.setPhoto(pt.Invert(b));
        }
예제 #4
0
        public void ProcessMosaic(int n)
        {
            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            WriteableBitmap         b  = p.getPhoto();

            p.setPhoto(pt.Mosaic(b, n));
        }
예제 #5
0
        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);
        }
예제 #6
0
        public void ProcessContract(int n)
        {
            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            WriteableBitmap         b  = p.getPhoto();

            p.setPhoto(pt.SetContrast(b, n));
        }
예제 #7
0
        public void ProcessContract(int n)
        {
            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            PhotoLayer      pl         = p.SelectLayer;
            WriteableBitmap b          = pl.ProcPhoto;

            pl.ProcPhoto = pt.SetContrast(b, n);
        }
예제 #8
0
        public void ProcessInvert()
        {
            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            PhotoLayer      pl         = p.SelectLayer;
            WriteableBitmap b          = pl.ProcPhoto;

            pl.ProcPhoto = pt.Invert(b);
        }
예제 #9
0
        public void ProcessMosaic(int n)
        {
            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            PhotoLayer      pl         = p.SelectLayer;
            WriteableBitmap b          = pl.ProcPhoto;

            pl.ProcPhoto = pt.Mosaic(b, n);
        }
예제 #10
0
        void li_MouseLeftButtonDown(object sender, PointerRoutedEventArgs e)
        {
            Image im = sender as Image;
            int   no = Convert.ToInt32(im.Tag);

            lChartPhoto1.Photo = (im.Source as WriteableBitmap);

            canvasBright.Children.Clear();
            DrawGraphic dgb = new DrawGraphic(canvasBright);

            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            List <int> hl = pt.getImageGrayHLine(im.Source as WriteableBitmap, (im.Source as WriteableBitmap).PixelHeight / 2);

            dgb.DrawBrightLines(hl);

            List <List <decimal> > al = new List <List <decimal> >();

            al = ptp.getCurveWaveQ(im.Source as WriteableBitmap, no);
            DrawCanvas.Children.Clear();
            DrawGraphic dg = new DrawGraphic(DrawCanvas);

            dg.DrawX();
            List <double> MarkList = new List <double>();
            int           step     = (al[0]).Count / 5;

            for (int i = 0; i < al[0].Count; i = i + step)
            {
                MarkList.Add(i);
            }
            dg.DrawXMark(MarkList);
            MarkList.Clear();
            for (int i = 0; i < 255; i = i + 40)
            {
                MarkList.Add(i);
            }
            dg.DrawY();
            dg.DrawYMark(MarkList);

            List <decimal> Sal, Val;

            Sal          = al[0];
            Val          = al[1];
            dg.ForeColor = Colors.Blue;
            dg.DrawLines(SilverlightLFC.common.Environment.getDoubleList <decimal>(Sal));
            dg.ForeColor = Colors.Red;
            dg.DrawLines(SilverlightLFC.common.Environment.getDoubleList <decimal>(Val));
            dg.DrawTitle("成像品质");

            textBlockCurrentBrightDis.Text = ptp.getWaveQ(im.Source as WriteableBitmap, no).ToString();
        }
예제 #11
0
        private void buttonAutoBright_Click(object sender, RoutedEventArgs e)
        {
            WriteableBitmap b = null;

            if (pc.SelectLayer != null)
            {
                b = pc.SelectLayer.getPhoto();
            }
            if (b != null)
            {
                DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
                b = pt.AutoBright(b);
                pc.SelectLayer.setPhoto(b, pc.ScalePercent);
            }
        }
예제 #12
0
        public void DrawHis()
        {
            WriteableBitmap b = null;

            if (pc.SelectLayer != null)
            {
                b = pc.SelectLayer.getPhoto();
            }
            if (b != null)
            {
                DrawGraphic             dg = new DrawGraphic(canvasBH);
                DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
                List <int> bl = pt.getBrightPixNum(b);
                dg.DrawBrightPixNumHistogram(bl);
            }
        }
예제 #13
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            WriteableBitmap b = null;

            if (pc != null)
            {
                b = pc.getPhoto();
            }
            if (b != null)
            {
                DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
                float sx, sy;
                sx = Convert.ToSingle(textBoxPixH.Text) / b.PixelHeight;
                sy = Convert.ToSingle(textBoxPixW.Text) / b.PixelWidth;
                b  = pt.ScaleBitmap(b, sx, sy).Result;
                pc.setPhoto(b);
            }
        }
예제 #14
0
        void image_MouseLeftButtonDown(object sender, PointerRoutedEventArgs e)
        {
            if (lChartPhoto1.Photo == null)
            {
                return;
            }
            double h = e.GetCurrentPoint(lChartPhoto1).Position.Y;
            int    H = Convert.ToInt32((lChartPhoto1.Photo).PixelHeight * (1 - h / lChartPhoto1.Height));

            canvasBright.Children.Clear();
            DrawGraphic dgb = new DrawGraphic(canvasBright);

            DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
            List <int> hl = pt.getImageGrayHLine((lChartPhoto1.Photo), H);

            dgb.DrawBrightLines(hl);
            //throw new NotImplementedException();
        }
예제 #15
0
        private async void button1_Click(object sender, RoutedEventArgs e)
        {
            WriteableBitmap b = null;

            if (pc.SelectLayer != null)
            {
                b = pc.SelectLayer.getPhoto();
            }
            if (b != null)
            {
                DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
                float sx, sy;
                sx = Convert.ToSingle(textBoxPixH.Text) / b.PixelHeight;
                sy = Convert.ToSingle(textBoxPixW.Text) / b.PixelWidth;
                b  = await pt.ScaleBitmap(b, sx, sy);

                pc.SelectLayer.setPhoto(b, pc.ScalePercent);
            }
        }
예제 #16
0
        private void currentBright_MouseMove(object sender, PointerRoutedEventArgs e)
        {
            LynxPhotoViewControl im = sender as LynxPhotoViewControl;
            WriteableBitmap      b  = im.getPhoto();

            if (b != null)
            {
                Point?p = xt.PointToPix(b, im, e.GetCurrentPoint(im.getImage()).Position, false);
                if (p == null)
                {
                    return;
                }
                DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
                Color c = pt.GetPixel(b, Convert.ToInt32(p.Value.X), Convert.ToInt32(p.Value.Y));
                float ph, ps, pb;
                pt.RGB2HSB(Convert.ToInt32(c.R), Convert.ToInt32(c.G), Convert.ToInt32(c.B), out ph, out ps, out pb);
                textBoxCurrentBright.Text = pb.ToString();
            }
        }
예제 #17
0
        public void Test(List <WriteableBitmap> b)
        {
            if (b.Count == 0 || b == null)
            {
                return;
            }
            bl = b;
            try
            {
                HB.Photo = (b[1]);
                VB.Photo = (b[2]);
                xt       = new XMarkChart();
                decimal d = xt.getBrightChanges(b[0]);//原始
                textBoxBrightChanges.Text = d.ToString();
                textBoxBB.Text            = xt.ProcessInfor["BrightChanges_BorderBright"].ToString();
                textBoxCB.Text            = xt.ProcessInfor["BrightChanges_CBright"].ToString();
                LT.Text = xt.ProcessInfor["BrightChanges_LT"].ToString();
                LB.Text = xt.ProcessInfor["BrightChanges_LB"].ToString();
                RT.Text = xt.ProcessInfor["BrightChanges_RT"].ToString();
                RB.Text = xt.ProcessInfor["BrightChanges_RB"].ToString();

                List <int> hl, vl;
                DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
                hl           = pt.getImageGrayHLine(b[1], b[1].PixelHeight / 2);
                vl           = pt.getImageGrayVLine(b[2], b[2].PixelWidth / 2);
                dg.ForeColor = Colors.Blue;
                dg.DrawBrightLines(hl);
                dg.ForeColor = Colors.Red;
                dg.DrawBrightLines(vl);
            }
            catch (Exception xe)        //未知的异常
            {
                if (xe is LFCException) //已经是系统约定的错误类型,直接往上抛
                {
                    SilverlightLFC.common.Environment.ShowMessage(xe.Message);
                }
                else
                {
                    SilverlightLFC.common.Environment.ShowMessage("测试错误,请检查照片");
                }
            }
        }
예제 #18
0
        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);
        }
예제 #20
0
        //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);
        }
예제 #21
0
        private void HB_PointerPressed(object sender, PointerRoutedEventArgs e)
        {
            LChartPhoto im = sender as LChartPhoto;

            selectedImage = im;

            HB.Active();
            VB.DeActive();
            photoTestToolbar1.setTarget(HB);
            WriteableBitmap b = im.getPhoto();

            if (b != null)
            {
                DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
                Point?p = xt.PointToPix(b, im, e.GetCurrentPoint(im).Position, false);
                if (p == null)
                {
                    return;
                }
                dg.DrawBrightLines(pt.getImageGrayHLine(b, Convert.ToInt32(p.Value.Y)));
            }
        }
예제 #22
0
        private void HB_MouseLeftButtonDown(object sender, PointerRoutedEventArgs e)
        {
            var im = sender as LynxPhotoViewControl;

            selectedImage = im;

            //HB.Active();
            //VB.DeActive();
            //photoTestToolbar1.setTarget(HB);
            WriteableBitmap b = im.Photo;

            if (b != null)
            {
                DCTestLibrary.PhotoTest pt = new DCTestLibrary.PhotoTest();
                Point?p = xt.PointToPix(b, im, e.GetCurrentPoint(im).Position, false);
                if (p == null)
                {
                    return;
                }
                dg.DrawBrightLines(pt.getImageGrayHLine(b, Convert.ToInt32(p.Value.Y)));
            }
        }
예제 #23
0
        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);
        }