Introduction
While I working in GUI design I need to ensure each and every pixel of the application, so I need a magnifier. I used the default Windows magnifier but it will not meet my zoom level and this requires implementing this magnifier with very simple logic.
Concept behind the approach
Here the actual need is to zoom in a specific region. We get the screenshot of the image and zoom it using the BitMap value and display. For lens representation we used a Form and PictureBox in which we have used "i" to zoom in and "o" to zoom out and "Esc" to close the form.
C# Code behind the approach
PictureBox pictureBox1 = new PictureBox(); // Have a picture box
int zoom = 1; // Variable for zoom value
public Form1()
{
pictureBox1.Dock = DockStyle.Fill; // Occupy the full area of the form
pictureBox1.BorderStyle = BorderStyle.FixedSingle; // Have a single border of clear representation
Controls.Add(pictureBox1); // Add the control to the form
FormBorderStyle = FormBorderStyle.None; // Make the form borderless to make it as lens look
Timer timer = new Timer(); // Have a timer for frequent update
timer.Interval = 100; // Set the interval for the timer
timer.Tick += timer_Tick; // Hool the event to perform desire action
timer.Start(); //Start the timer
printscreen = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height); // Have a bitmap to store the image of the screen
}
void timer_Tick(object sender, EventArgs e)
{
var graphics = Graphics.FromImage(printscreen as Image); // Get the image of the captured screen
graphics.CopyFromScreen(0, 0, 0, 0, printscreen.Size); // Get the copy of screen
var position = Cursor.Position; // Get the position of cursor
var lensbmp = new Bitmap(50, 50); // Have a bitmap for lens
var i = 0; // Variable for row count


simon robertsPosted Mar 6, 2016, 2:47 PM
Bitmap printscreen = new Bitmap et ceteta.