Ejemplo n.º 1
0
        public MagWindow(ImageMap iMap, bool imageFit)
        {
            InitializeComponent();

            this.iMap = iMap;
            Bitmap image = iMap.getBitmap();

            pictureBox.Image = image;
            pictureBox.Size = image.Size;

            // Resize window
            int newWidth = Math.Max(this.PreferredSize.Width, 305);
            int newHeight = Math.Max(this.PreferredSize.Height, 246);
            if (!imageFit)
            {
                newWidth = Math.Min(newWidth, Screen.PrimaryScreen.Bounds.Width * 2 / 3);
                newHeight = Math.Min(newHeight, Screen.PrimaryScreen.Bounds.Height * 2 / 3);
            }
            this.Size = new Size(newWidth, newHeight);

            trackBar.Maximum = Math.Min(500, Math.Min(image.Width / 2, image.Height / 2));
            trackBar.Value = Math.Min(trackBar.Value, trackBar.Maximum);
            magBoxSizeLabel.Text = trackBar.Value.ToString();

            pen = new Pen(Color.White, 2);
            box = new Rectangle(0, 0, 0, 0);

            overlayPicture.Parent = pictureBox;
        }
Ejemplo n.º 2
0
        public ImageMap crop(int xStart, int yStart, int height, int width)
        {
            ImageMap iMap = new ImageMap();

            iMap.height = height;
            iMap.width = width;
            iMap.isColor = isColor;

            iMap.Y = new int[height, width];

            if (!isColor)
            {
                for (int x = xStart; x < xStart + height; x++)
                {
                    for (int y = yStart; y < yStart + width; y++)
                    {
                        iMap.Y[x - xStart, y - yStart] = Y[x, y];
                    }
                }
            }
            else
            {
                iMap.I = new int[height, width];
                iMap.Q = new int[height, width];
                iMap.R = new byte[height, width];
                iMap.G = new byte[height, width];
                iMap.B = new byte[height, width];

                for (int x = xStart; x < xStart + height; x++)
                {
                    for (int y = yStart; y < yStart + width; y++)
                    {
                        iMap.Y[x - xStart, y - yStart] = Y[x, y];
                        iMap.I[x - xStart, y - yStart] = I[x, y];
                        iMap.Q[x - xStart, y - yStart] = Q[x, y];
                        iMap.R[x - xStart, y - yStart] = R[x, y];
                        iMap.G[x - xStart, y - yStart] = G[x, y];
                        iMap.B[x - xStart, y - yStart] = B[x, y];
                    }
                }
            }

            return iMap;
        }