예제 #1
0
        private void Image_MouseClicked(object sender, MouseButtonEventArgs e)
        {
            if (Equals(sender, OriginalImage))
            {
                if (OriginalImage.IsMouseCaptured)
                {
                    return;
                }

                OriginalImage.CaptureMouse();
                start = e.GetPosition(OriginalBorder);
            }

            if (Equals(sender, ModifiedImage))
            {
                if (ModifiedImage.IsMouseCaptured)
                {
                    return;
                }

                ModifiedImage.CaptureMouse();
                start = e.GetPosition(ModifiedBorder);
            }

            origin.X = OriginalImage.RenderTransform.Value.OffsetX;
            origin.Y = OriginalImage.RenderTransform.Value.OffsetY;


            try
            {
                if (e.ClickCount != 2)
                {
                    return;
                }
                var image = (Image)sender;

                var proportionheight = _originalImgBitmap.PixelHeight / image.ActualHeight;
                var proportionwidth  = _originalImgBitmap.PixelWidth / image.ActualWidth;
                var point            = e.GetPosition(OriginalImage);
                var x = point.X * proportionwidth;
                var y = point.Y * proportionheight;
                CoordinatesXy.Text = "X: " + (int)x + " Y: " + (int)y;

                //OriginalImage.Source = SquareTesting.MarkSquares(originalBitmapSource, (int)x, (int)y);
                //ModifiedImage.Source = SquareTesting.CheckForPotentialMinutia(originalBitmapSource, (int)x, (int)y);
                ModifiedImgSingleton.Source = SquareTesting.DeleteRepetations((BitmapSource)ModifiedImgSingleton.Source, (int)x, (int)y);
                pixels = new byte[4];

                var bitmap = new CroppedBitmap(_originalImgBitmap,
                                               new Int32Rect((int)x, (int)y, 1, 1));

                try
                {
                    bitmap.CopyPixels(pixels, 4, 0);
                }
                catch (Exception exc)
                {
                    Debug.WriteLine(exc.StackTrace);
                }

                //var changePixel = new RgbDialog(pixels, point, _originalImgBitmap);
                //changePixel.Show();
            }
            catch (Exception ee)
            {
                Debug.WriteLine(ee.StackTrace);
            }
        }