Reputation: 2259
I am very curious to know how "Print" button capture current screen? When we press "print" button what happens? How it'll capture the screen?
Please let me know if anyone know about the same.
Thanks, Jimit
Upvotes: 0
Views: 101
Reputation: 8597
ORIGINAL USE
Under command-line based operating systems such as MS-DOS, this key causes the contents of the current text mode screen memory buffer to be copied to the standard printer port, usually LPT1. In essence, whatever was currently on the screen when the key was pressed was printed. Pressing the Ctrl key in combination with Prt Sc turns on and off the "printer echo" feature. When echo is in effect, any conventional text output to the screen will be copied ("echoed") to the printer. There is also a Unicode character for print screen, U+2399 ⎙
.
MODERN USE
Newer-generation operating systems using a graphical interface tend to copy a bitmap image of the current screen to their clipboard or comparable storage area, which can be inserted into documents as a screenshot. Some shells allow modification of the exact behavior using modifier keys such as the control key.
Macintosh does not use a print screen key; instead, key combinations are used that start with ⌘ Cmd+⇧ Shift.
.
Coding
For example a C# code can run to take a screenshot:
private void PrtScr() {
Bitmap bm = new Bitmap(Screen.PrimaryScreen.Bounds.Width,
Screen.PrimaryScreen.Bounds.Height);
Graphics g = Graphics.FromImage(bm as Image);
g.CopyFromScreen(0, 0, 0, 0, bm.Size);
bm.Save(@"C:\image.jpeg", ImageFormat.Jpeg);
}
For example Java code:
class ScreenRecorder {
public static void main(String args[]) {
try {
Toolkit tool = Toolkit.getDefaultToolkit();
Dimension d = tool.getScreenSize();
Rectangle rect = new Rectangle(d);
Robot robot = new Robot();
Thread.sleep(2000);
File f = new File("screenshot.jpg");
BufferedImage img = robot.createScreenCapture(rect);
ImageIO.write(img,"jpeg",f);
tool.beep();
} catch(Exception e){
e.printStackTrace();
}
}
}
Upvotes: 1