0

I followed the following in post on"Creating a screen magnifier".

Therefore I have this code. It is not copy & pasted from the post. I have also added a timer so the form is not blank. However I have found some problems.

  1. It doesn't zoom in very much. I would like to have a larger zoom. An adjustable zoom setting will be optimal, but I can make that myself if I know how to zoom in more.
  2. The center of the form is not always the tip of the cursor like I want it would be. Is there anyway I can Fix this?

Here is the code I have got now.

Graphics g;
Bitmap bmp;
private void Timer1_Tick(object sender, EventArgs e)
{
    bmp = new Bitmap(250, 200);
    g = this.CreateGraphics();
    g = Graphics.FromImage(bmp);
    g.CopyFromScreen(MousePosition.X , MousePosition.Y , 0, 0, new Size(300, 300));
    pictureBox1.Image = bmp;
}

The results seem to be exactly the same to this software that I found during my research.the link, It takes you to a Japanese webpage.

Community
  • 1
  • 1
Atom Scott
  • 59
  • 1
  • 10

1 Answers1

1

You're going to have to play around with the various numbers in the example in order to see what effect they have on the output. It'll help to turn them into variables so you can play with them more easily. Here is a good start, no promises that it works, but it'll give you a good place to start experimenting until you get what you want.

Graphics g;
Bitmap bmp;
private void Timer1_Tick(object sender, EventArgs e)
{
    var endWidth = 300;
    var endHeight = 300;

    var scaleFactor = 2; //perhaps get this value from a const, or an on screen slider

    var startWidth = endWidth / scaleFactor;
    var startHeight = endHeight / scaleFactor;

    bmp = new Bitmap(startWidth, startHeight);

    g = this.CreateGraphics();
    g = Graphics.FromImage(bmp);

    var xPos = Math.Max(0, MousePosition.X - (startWidth/2)); // divide by two in order to center
    var yPos = Math.Max(0, MousePosition.Y - (startHeight/2));

    g.CopyFromScreen(xPos, yPos, 0, 0, new Size(endWidth, endWidth));
    pictureBox1.Image = bmp;
}
viggity
  • 15,039
  • 7
  • 88
  • 96