Exemplo n.º 1
0
        private void Confirm_Click(object sender, EventArgs e)
        {
            buffer[index] = new Poly(clkpoint, ang);
            ++index;
            Zoom f = new Zoom(index);

            f.mf = this;
            Image    img = new Bitmap(800, 600);
            Image    org = new Bitmap(rgIMD[cur].GetImg());
            Graphics g = Graphics.FromImage(img);
            int      lx, rx, ly, ry;
            double   ra, rax, ray;

            lx  = Math.Min(newpoint[0].X, newpoint[1].X); lx = Math.Min(lx, newpoint[2].X); lx = Math.Min(lx, newpoint[3].X);
            rx  = Math.Max(newpoint[0].X, newpoint[1].X); rx = Math.Max(rx, newpoint[2].X); rx = Math.Max(rx, newpoint[3].X);
            ly  = Math.Min(newpoint[0].Y, newpoint[1].Y); ly = Math.Min(ly, newpoint[2].Y); ly = Math.Min(ly, newpoint[3].Y);
            ry  = Math.Max(newpoint[0].Y, newpoint[1].Y); ry = Math.Max(ry, newpoint[2].Y); ry = Math.Max(ry, newpoint[3].Y);
            rax = 800.0 / (double)(rx - lx);
            ray = 600.0 / (double)(ry - ly);
            ra  = Math.Min(rax, ray);
            g.Clear(Color.White);
            g.InterpolationMode = InterpolationMode.High;
            g.SmoothingMode     = SmoothingMode.HighQuality;
            g.DrawImage(org, new Rectangle(0, 0, (int)(ra * (rx - lx)), (int)(ra * (ry - ly))), new Rectangle(lx, ly, rx - lx, ry - ly), GraphicsUnit.Pixel);
            f.setdata(ra, lx, ly);
            f.Zoompicbox.Image = img;
            f.Show();
            AddPoly();
            selected = -1;
            OperateClick();
        }
Exemplo n.º 2
0
        private void edittext_Click(object sender, EventArgs e)
        {
            Zoom f = new Zoom(selected + 1);

            f.mf = this;
            Image    img = new Bitmap(800, 600);
            Image    org = new Bitmap(rgIMD[cur].GetImg());
            Graphics g = Graphics.FromImage(img);
            int      lx, rx, ly, ry;
            double   ra, rax, ray;

            Point[] newp = new Point[4];
            newp[0] = new Point(buffer[selected].rgP[0].X, buffer[selected].rgP[0].Y);
            newp[2] = new Point(buffer[selected].rgP[1].X, buffer[selected].rgP[1].Y);
            if (buffer[selected].angle == 0 || buffer[selected].angle == 90 || buffer[selected].angle == -90)
            {
                newp[1] = new Point(newp[0].X, newp[2].Y);
                newp[3] = new Point(newp[2].X, newp[0].Y);
            }
            else
            {
                double alp  = buffer[selected].angle / 180.0 * Math.PI;
                double beta = Math.Atan2((double)(newp[2].Y - newp[0].Y), (double)(newp[2].X - newp[0].X));
                double le   = Math.Sqrt((newp[2].Y - newp[0].Y) * (newp[2].Y - newp[0].Y) + (newp[2].X - newp[0].X) * (newp[2].X - newp[0].X));
                int    mx   = (int)(le * Math.Cos(alp - beta) * Math.Cos(alp));
                int    my   = (int)(le * Math.Cos(alp - beta) * Math.Sin(alp));
                newp[1] = new Point(newp[0].X + mx, newp[0].Y + my);
                newp[3] = new Point(newp[2].X - mx, newp[2].Y - my);
            }
            lx  = Math.Min(newp[0].X, newp[1].X); lx = Math.Min(lx, newp[2].X); lx = Math.Min(lx, newp[3].X);
            rx  = Math.Max(newp[0].X, newp[1].X); rx = Math.Max(rx, newp[2].X); rx = Math.Max(rx, newp[3].X);
            ly  = Math.Min(newp[0].Y, newp[1].Y); ly = Math.Min(ly, newp[2].Y); ly = Math.Min(ly, newp[3].Y);
            ry  = Math.Max(newp[0].Y, newp[1].Y); ry = Math.Max(ry, newp[2].Y); ry = Math.Max(ry, newp[3].Y);
            rax = 800.0 / (double)(rx - lx);
            ray = 600.0 / (double)(ry - ly);
            ra  = Math.Min(rax, ray);
            g.Clear(Color.White);
            g.InterpolationMode = InterpolationMode.High;
            g.SmoothingMode     = SmoothingMode.HighQuality;
            g.DrawImage(org, new Rectangle(0, 0, (int)(ra * (rx - lx)), (int)(ra * (ry - ly))), new Rectangle(lx, ly, rx - lx, ry - ly), GraphicsUnit.Pixel);
            f.setdata(ra, lx, ly);
            f.setstr(buffer[selected].name);
            f.Zoompicbox.Image = img;
            f.Show();
            selected = -1;
            OperateClick();
        }