Exemplo 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);
        }
Exemplo n.º 2
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();
            }
        }