c# - Zoom lens on diferent screen resolutions -




i´m using code create zoom lens, working fine on computer, when try program run on notebook (not 1080p screen) not working correctly.

what lens show part of image, part mouse hover, in square zoomed. on other computers not showing part mouse is, zoomed part showed far way mouse pointer.

what should code work on others computers resolutions??

public partial class formlens : form {     picturebox picturebox1 = new picturebox(); // have picture box     int zoom = 4; // variable zoom value     bitmap printscreen;     timer timer = new timer();     public formlens()     {         initializecomponent();           picturebox1.dock = dockstyle.fill; // occupy full area of form         picturebox1.borderstyle = borderstyle.fixedsingle; // have single border of clear representation         controls.add(picturebox1); // add control form         formborderstyle = formborderstyle.none; // make form borderless make lens          timer.interval = 100; // set interval timer         timer.tick += timer_tick; // hool event perform desire action         timer.start(); //start timer         printscreen = new bitmap(screen.primaryscreen.bounds.width, screen.primaryscreen.bounds.height); // have bitmap store image of screen              }        void timer_tick(object sender, eventargs e)     {         var graphics = graphics.fromimage(printscreen image); // image of captured screen         graphics.copyfromscreen(0, 0, 0, 0, printscreen.size); // copy of screen         var position = cursor.position; // position of cursor         var lensbmp = new bitmap(50, 50); // have bitmap lens         var = 0; // variable row count         var j = 0; // variable column count         (int row = position.x - 25; row < position.x + 25; row++) // indicates row number         {             j = 0; // set column value '0' new column             (int column = position.y - 25; column < position.y + 25; column++) // indicate column number             {                 try                 {                     lensbmp.setpixel(i, j, printscreen.getpixel(row, column)); // place current region pixel lens bitmap                     j++; // increase row count                 }                 catch                 {                     timer.stop();                     timer.dispose();                     this.close();                                                                     //messagebox.show("lente dos limites da tela");                     break;                 }               }             i++; // increase column count         }         this.picturebox1.image = new bitmap(lensbmp, lensbmp.width * zoom, lensbmp.height * zoom); // assign lens bitmap zoom level picture box         size = picturebox1.image.size; // assign optimal value form         left = position.x + 25; // place form nearer cursor x value         top = position.y + 25; // place form nearer cursor y value         topmost = true; // keep form top level     }      // override onkeydown zoom in , zoom out actions     protected override void onkeydown(keyeventargs e)     {         if (e.keyvalue == 73) // set "i" key zoom in.             zoom++; // increase zoom 1 item greater         else if (e.keyvalue == 79) // set "o" key zoom out             zoom--; // decrease zoom 1 item smaller         else if (e.keyvalue == 27) // set "esc" close magnifier         {             timer.stop();             timer.dispose();             this.close(); // close form                            dispose(); // dispose form          }         base.onkeydown(e);     }           } 





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -