Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Form1()
- {
- InitializeComponent();
- pictureBox1.Image = Bitmap.FromFile("lena.png");
- }
- Point CurMouse;
- const int SrcWin = 20; //source window size
- const int DstWin = 80; //destination window size
- const int DistMouse = 30; //distance to mouse
- private void pictureBox1_Paint(object sender, PaintEventArgs e)
- {
- Graphics g = e.Graphics;
- g.InterpolationMode = InterpolationMode.NearestNeighbor;
- g.CompositingQuality = CompositingQuality.HighSpeed;
- g.SmoothingMode = SmoothingMode.None;
- g.PixelOffsetMode = PixelOffsetMode.Half;
- //zoom window (zooming image of picturebox)
- g.DrawImage(pictureBox1.Image, new Rectangle(CurMouse.X + DistMouse, CurMouse.Y + DistMouse, DstWin, DstWin),
- CurMouse.X - (SrcWin / 2), CurMouse.Y - (SrcWin / 2), SrcWin, SrcWin, GraphicsUnit.Pixel);
- g.PixelOffsetMode = PixelOffsetMode.Default;
- //draw text (should have inverted/good visible colors, depending on current background of zoom window)
- TextRenderer.DrawText(g, CurMouse.X + "," + CurMouse.Y, new Font("Arial", 12),
- new Point(CurMouse.X + DistMouse, CurMouse.Y + DistMouse), Color.Red);
- }
- private void pictureBox1_MouseMove(object sender, MouseEventArgs e)
- {
- CurMouse = e.Location;
- pictureBox1.Invalidate();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement