Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 4
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);
        }