Esempio n. 1
0
        private void inverColorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Bitmap bmp;

            if (zoomPicBox1.Image != null)
            {
                bmp = ImageProcessing.InvertColor(zoomPicBox1.Image);
                FormVisualizer form2 = new FormVisualizer(FormVisualizer.DisplayMode.Form1, "");
                form2.SetPicture(bmp);
                form2.Show();
            }
        }
Esempio n. 2
0
        void DrawCursor(MouseEventArgs e)
        {
            int OriginalX, OriginalY;
            int ScaledX, ScaledY;
            int i, BrushLenght;

            Refresh();

            //New method for drawing cursor
            if ((_image != null) && (0 < e.X) && (e.X < this.ClientRectangle.Width) && // Checking if mouse is not dragging outside the ZoomPicBox
                (0 < e.Y) && (e.Y < this.ClientRectangle.Height))
            {
                //Coordinates of first pixel on the screen on X axis
                ScaledY = -this.AutoScrollPosition.Y + e.Y;
                OriginalX = (int)(-this.AutoScrollPosition.X / this.Zoom);
                OriginalY = (int)(ScaledY / this.Zoom);

                //Drawing with the color until start of new pixel
                brushMouse.Color = ImageProcessing.InvertColor(GetPixelMod(OriginalX, OriginalY));
                for (i = 0; i < this.ClientRectangle.Width; i++) // Drawing X cursor Line
                {
                    ScaledX = -this.AutoScrollPosition.X + i;
                    if (ScaledX % this.Zoom == 0) // Reaching new pixel and changing the brush color according to
                    {
                        OriginalX = (int)(ScaledX / this.Zoom);
                        brushMouse.Color = ImageProcessing.InvertColor(GetPixelMod(OriginalX, OriginalY));
                        BrushLenght = Math.Max((int)this.Zoom, 1); // If Zoom < 1 Draws 1 pixel, otherwise pixels are Zoom count
                        DisplayedArea.FillRectangle(brushMouse, i, e.Y, BrushLenght, 1); //Draws the equal pixels
                        i += BrushLenght - 1; // Skips the equal pixels (when zoomed)
                    }
                    else
                    {
                        DisplayedArea.FillRectangle(brushMouse, i, e.Y, 1, 1);
                    }
                }

                //Coordinates of first pixel on the screen on Y axis
                ScaledX = -this.AutoScrollPosition.X + e.X;
                OriginalX = (int)(ScaledX / this.Zoom);
                OriginalY = (int)(-this.AutoScrollPosition.Y / this.Zoom);

                //Drawing with the color until start of new pixel
                brushMouse.Color = ImageProcessing.InvertColor(GetPixelMod(OriginalX, OriginalY));
                for (i = 0; i < this.ClientRectangle.Height; i++) // Drawing X cursor Line
                {
                    ScaledY = -this.AutoScrollPosition.Y + i;
                    if (ScaledY % this.Zoom == 0) // Reaching new pixel and changing the brush color according to
                    {
                        OriginalY = (int)(ScaledY / this.Zoom);
                        brushMouse.Color = ImageProcessing.InvertColor(GetPixelMod(OriginalX, OriginalY));
                        BrushLenght = Math.Max((int)this.Zoom, 1); // If Zoom < 1 Draws 1 pixel, otherwise pixels are Zoom count
                        DisplayedArea.FillRectangle(brushMouse, e.X, i, 1, BrushLenght); //Draws the equal pixels
                        i += BrushLenght - 1; // Skips the equal pixels (when zoomed)
                    }
                    else
                    {
                        DisplayedArea.FillRectangle(brushMouse, e.X, i, 1, 1);
                    }
                }
            }
            else if (_image == null)
            {
                penMouse.Color = Color.Black;
                DisplayedArea.DrawLine(penMouse, 0, e.Y, this.ClientRectangle.Width, e.Y); //X cursor line
                DisplayedArea.DrawLine(penMouse, e.X, 0, e.X, this.ClientRectangle.Height); //Y cursor line
                DisplayedArea.DrawRectangle(penMouse, e.X - 5, e.Y - 5, 10, 10);
            }

            //Old method for drawing cursor
            //if ((0 < e.X) && (e.X < DisplayedImage.Width) && // Checking if mouse is not dragging outside the ZoomPicBox
            //    (0 < e.Y) && (e.Y < DisplayedImage.Height))
            //{
            //    for (int i = 0; i < DisplayedImage.Width; i += 5) // Drawing X cursor Line, each 5 pixels are equal to lower the flickering during redrawing cursor
            //    {
            //        brushMouse.Color = ImageProcessing.InvertColor(DisplayedImage.GetPixel(i, e.Y));
            //        DisplayedArea.FillRectangle(brushMouse, i, e.Y, 5, 1);
            //    }
            //    for (int i = 0; i < DisplayedImage.Height; i += 5) // Drawing Y cursor Line
            //    {
            //        brushMouse.Color = ImageProcessing.InvertColor(DisplayedImage.GetPixel(e.X, i));
            //        DisplayedArea.FillRectangle(brushMouse, e.X, i, 1, 5);
            //    }
            //    penMouse.Color = ImageProcessing.InvertColor(DisplayedImage.GetPixel(e.X, e.Y));
            //    DisplayedArea.DrawRectangle(penMouse, e.X - 5, e.Y - 5, 10, 10);
            //}
            //else if (_image == null)
            //{
            //    penMouse.Color = Color.Black;
            //    DisplayedArea.DrawLine(penMouse, 0, e.Y, this.ClientRectangle.Width, e.Y); //X cursor line
            //    DisplayedArea.DrawLine(penMouse, e.X, 0, e.X, this.ClientRectangle.Height); //Y cursor line
            //    DisplayedArea.DrawRectangle(penMouse, e.X - 5, e.Y - 5, 10, 10);
            //}
        }