private void InitializeMagnificationImage()
        {
            if (_magnificationImage != null)
            {
                return;
            }

            if (SelectedPresentationImage == null)
            {
                throw new ArgumentException("The image cannot be null", "value");
            }

            if (!(SelectedPresentationImage is ISpatialTransformProvider))
            {
                throw new ArgumentException("The image must implement ISpatialTransformProvider", "value");
            }

            if (!(((ISpatialTransformProvider)SelectedPresentationImage).SpatialTransform is ImageSpatialTransform))
            {
                throw new ArgumentException("The image must provide an IImageSpatialTransform", "value");
            }

            DisposeMagnificationImage();

            _firstRender        = true;
            _magnificationImage = (PresentationImage)SelectedPresentationImage.Clone();

            HideOverlays();
        }
 private void DisposeMagnificationImage()
 {
     if (_magnificationImage != null)
     {
         _magnificationImage.Dispose();
         _magnificationImage = null;
     }
 }
        public void PrintPreviewCopy()
        {
            if (this.ImageViewer.SelectedImageBox == null || this.ImageViewer.SelectedImageBox.DisplaySet == null || this.Context.Viewer.SelectedPresentationImage == null)
            {
                return;
            }
            var imageBox = this.ImageViewer.SelectedImageBox;
            PrintImageViewerComponent component = this.Context.Viewer as PrintImageViewerComponent;

            if (component == null)
            {
                return;
            }

            if (selectPresentationImages == null)
            {
                selectPresentationImages = new List <IPresentationImage>();
            }
            else
            {
                selectPresentationImages.Clear();
            }

            foreach (var selectPresentationImage in component.SelectPresentationImages)
            {
                PresentationImage image = ImageExporter.ClonePresentationImage(selectPresentationImage) as PresentationImage;
                if (image == null)
                {
                    continue;
                }
                image.Selected = false;
                selectPresentationImages.Add(image);
            }

            foreach (PrintViewTile tile in imageBox.Tiles)
            {
                if (tile.PresentationImage == null)
                {
                    tile.Deselect();
                }
            }
        }
        public override bool Start(InputManagement.IMouseInformation mouseInformation)
        {
            if (mouseInformation.ClickCount < 2)
            {
                return(false);
            }

            PrintImageViewerComponent printImageViewer = this.Context.Viewer as PrintImageViewerComponent;

            if (printImageViewer == null || printImageViewer.SelectPresentationImages == null)
            {
                return(false);
            }

            foreach (var item in printImageViewer.SelectPresentationImages)
            {
                PresentationImage image = item as PresentationImage;
                image.Selected = false;
            }
            printImageViewer.SelectPresentationImages.Clear();

            foreach (PrintViewTile tile in this.Context.Viewer.SelectedImageBox.Tiles)
            {
                if (tile.PresentationImage == null)
                {
                    tile.Deselect();
                    continue;
                }
                PresentationImage image = tile.PresentationImage as PresentationImage;
                image.Selected = true;
                printImageViewer.SelectPresentationImages.Add(image);
            }

            if (printImageViewer.SelectPresentationImages.Count > 0)
            {
                PrintViewImageBox imageBox = printImageViewer.SelectedImageBox as PrintViewImageBox;
                imageBox.SelectedTile = printImageViewer.SelectPresentationImages[0].Tile;
            }
            this.Context.Viewer.SelectedImageBox.Draw();

            return(true);
        }
        private void SelectRever(object sender, EventArgs args)
        {
            PrintImageViewerComponent printImageViewer = Context.Viewer as PrintImageViewerComponent;

            if (printImageViewer == null || printImageViewer.SelectPresentationImages == null)
            {
                return;
            }

            foreach (PrintViewTile tile in this.Context.Viewer.SelectedImageBox.Tiles)
            {
                if (tile.PresentationImage == null)
                {
                    tile.Deselect();
                }
            }

            List <PresentationImage> temp = new List <PresentationImage>();

            foreach (var tile in printImageViewer.DisplaySet.PresentationImages)
            {
                PresentationImage image = tile as PresentationImage;
                if (printImageViewer.SelectPresentationImages.Contains(image))
                {
                    image.Selected = false;
                }
                else
                {
                    image.Selected = true;
                    temp.Add(image);
                }
            }
            printImageViewer.SelectPresentationImages.Clear();
            printImageViewer.SelectPresentationImages.AddRange(temp);

            if (printImageViewer.SelectPresentationImages.Count > 0)
            {
                PrintViewImageBox imageBox = printImageViewer.SelectedImageBox as PrintViewImageBox;
                imageBox.SelectedTile = printImageViewer.SelectPresentationImages[0].Tile;
            }
            this.Context.Viewer.SelectedImageBox.Draw();
        }
Example #6
0
        public MagnificationForm(PresentationImage image, Point startPointTile, RenderMagnifiedImage render)
		{
			InitializeComponent();

            Visible = false;
			this.DoubleBuffered = false;
			this.SetStyle(ControlStyles.DoubleBuffer, false);
			this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
			this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

			if (Form.ActiveForm != null)
				this.Owner = Form.ActiveForm;

			_startPointTile = startPointTile;
            _render = render;

            _surface = image.ImageRenderer.GetRenderingSurface(Handle, ClientRectangle.Width, ClientRectangle.Height);

            _startPointDesktop = Centre = Cursor.Position;
		}
        public MagnificationForm(PresentationImage image, Point startPointTile, RenderMagnifiedImage render)
        {
            InitializeComponent();

            Visible             = false;
            this.DoubleBuffered = false;
            this.SetStyle(ControlStyles.DoubleBuffer, false);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
            this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

            if (Form.ActiveForm != null)
            {
                this.Owner = Form.ActiveForm;
            }

            _startPointTile = startPointTile;
            _render         = render;

            _surface = image.ImageRenderer.GetRenderingSurface(Handle, ClientRectangle.Width, ClientRectangle.Height);

            _startPointDesktop = Centre = Cursor.Position;
        }
Example #8
0
        public MagnificationForm(float magnificationFactor, PresentationImage sourceImage, Point startPointTile)
        {
            InitializeComponent();

            Visible             = false;
            this.DoubleBuffered = false;
            this.SetStyle(ControlStyles.DoubleBuffer, false);
            this.SetStyle(ControlStyles.OptimizedDoubleBuffer, false);
            this.SetStyle(ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true);

            if (Form.ActiveForm != null)
            {
                this.Owner = Form.ActiveForm;
            }

            MagnificationFactor = magnificationFactor;
            SourceImage         = sourceImage;

            _sourcePointOfInterest = ((ImageSpatialTransform)((ISpatialTransformProvider)sourceImage).SpatialTransform).ConvertToSource(startPointTile);
            _startPointTile        = startPointTile;
            _startPointDesktop     = Centre = Cursor.Position;
        }
        private void SelectAll(object sender, EventArgs args)
        {
            PrintImageViewerComponent printImageViewer = Context.Viewer as PrintImageViewerComponent;

            if (printImageViewer == null || printImageViewer.SelectPresentationImages == null)
            {
                return;
            }

            foreach (PrintViewTile tile in this.Context.Viewer.SelectedImageBox.Tiles)
            {
                if (tile.PresentationImage == null)
                {
                    tile.Deselect();
                }
            }

            foreach (var item in printImageViewer.SelectPresentationImages)
            {
                PresentationImage image = item as PresentationImage;
                image.Selected = false;
            }
            printImageViewer.SelectPresentationImages.Clear();

            foreach (var tile in printImageViewer.DisplaySet.PresentationImages)
            {
                PresentationImage image = tile as PresentationImage;
                image.Selected = true;
                printImageViewer.SelectPresentationImages.Add(image);
            }

            if (printImageViewer.SelectPresentationImages.Count > 0)
            {
                PrintViewImageBox imageBox = printImageViewer.SelectedImageBox as PrintViewImageBox;
                imageBox.SelectedTile = printImageViewer.SelectPresentationImages[0].Tile;
            }
            this.Context.Viewer.SelectedImageBox.Draw();
        }
Example #10
0
 public void Open(float magnificationFactor, PresentationImage image, Point location)
 {
     _form = new MagnificationForm(magnificationFactor, image, location);
     _form.Show();
 }
Example #11
0
		public void Open(float magnificationFactor, PresentationImage image, Point location)
		{
			_form = new MagnificationForm(magnificationFactor, image, location);
			_form.Show();
		}
Example #12
0
 private void DisposeMagnificationImage()
 {
     if (_magnificationImage != null)
     {
         _magnificationImage.Dispose();
         _magnificationImage = null;
     }
 }
Example #13
0
        private void InitializeMagnificationImage()
        {
            if (_magnificationImage != null)
                return;

            if (SelectedPresentationImage == null)
                throw new ArgumentException("The image cannot be null", "value");

            if (!(SelectedPresentationImage is ISpatialTransformProvider))
                throw new ArgumentException("The image must implement ISpatialTransformProvider", "value");

            if (!(((ISpatialTransformProvider)SelectedPresentationImage).SpatialTransform is ImageSpatialTransform))
                throw new ArgumentException("The image must provide an IImageSpatialTransform", "value");

            DisposeMagnificationImage();

            _firstRender = true;
            _magnificationImage = (PresentationImage)SelectedPresentationImage.Clone();

            HideOverlays();
        }
Example #14
0
        internal unsafe static void Main(string[] args)
        {
            try
            {
                int    pixelsCount = 1 << 18;
                uint[] pixelsArray = new uint[65536];

                using (DisposableHandle handle = DisposableHandle.Alloc(pixelsArray))
                {
                    NTInvoke.SetUnmanagedMemory(handle, 255, pixelsCount);
                }

                byte[] outputData = null;

                MCvScalar redColor   = MCvScalarExtensions.FromColor(Colors.Red);
                MCvScalar greenColor = MCvScalarExtensions.FromColor(Colors.Green);

                using (PresentationImage prImage = new PresentationImage(256, 256))
                {
                    prImage.WritePixels(pixelsArray);

                    FontFace[] faces = new FontFace[]
                    {
                        FontFace.HersheyComplex,
                        FontFace.HersheyComplexSmall,
                        FontFace.HersheyDuplex,
                        FontFace.HersheyPlain,
                        FontFace.HersheyScriptComplex,
                        FontFace.HersheyScriptSimplex,
                        FontFace.HersheySimplex,
                        FontFace.HersheyTriplex
                    };

                    Parallel.For(0, 8, (int index) =>
                    {
                        Point drawPoint   = new Point(10, 30 + 30 * index);
                        FontFace drawFace = faces[index];

                        string outputText = Enum.GetName(typeof(FontFace), drawFace);

                        CvInvoke.DrawText(prImage, outputText, drawPoint, drawFace, 1.0D, redColor, 1);
                    });

                    outputData = CvInvoke.Imencode(prImage, ImageEncoding.Jpeg, new int[] { 95 });
                }

                if (outputData != null && outputData.Length > 0)
                {
                    using (MemoryStream dataStream = new MemoryStream(outputData))
                    {
                        JpegBitmapDecoder decoder = new JpegBitmapDecoder(dataStream, BitmapCreateOptions.DelayCreation, BitmapCacheOption.OnLoad);
                        BitmapFrame       frame   = decoder.Frames[0];

                        Window imageWindow = new Window()
                        {
                            Height                = 300.0D,
                            Width                 = 500.0D,
                            Title                 = "Image window",
                            ResizeMode            = ResizeMode.CanResize,
                            WindowStartupLocation = WindowStartupLocation.CenterScreen
                        };
                        imageWindow.Content = new Image()
                        {
                            Source = frame
                        };
                        new Application().Run(imageWindow);
                    }
                }
            }
            catch (Exception exc)
            {
                Debug.WriteLine("\tCatched exception: {0}\r\n{1}", exc.Message, exc);
            }
            finally
            {
                Debug.WriteLine("\tData released succesfully.");
            }
        }