runelite-client/src/main/java/net/runelite/client/plugins/screenshot/ScreenshotPlugin.java
/**
	 * Saves a screenshot of the client window to the screenshot folder as a PNG,
	 * and optionally uploads it to an image-hosting service.
	 *
	 * @param fileName    Filename to use, without file extension.
	 */
Saves a screenshot of the client window to the screenshot folder as a PNG,
and optionally uploads it to an image-hosting service.

@param fileName    Filename to use, without file extension.
Saves a screenshot of the client window to the screenshot folder as a PNG and optionally uploads it to an image - hosting service . @param fileName Filename to use without file extension .
void takeScreenshot(String fileName)
	{
		if (client.getGameState() == GameState.LOGIN_SCREEN)
		{
			log.info("Login screenshot prevented");
			return;
		}
		Consumer<BufferedImage> screenshotConsumer = image ->
		{
			BufferedImage screenshot = config.includeFrame()
				? new BufferedImage(clientUi.getWidth(), clientUi.getHeight(), BufferedImage.TYPE_INT_ARGB)
				: new BufferedImage(image.getWidth(), image.getHeight(), BufferedImage.TYPE_INT_ARGB);
			Graphics graphics = screenshot.getGraphics();
			int gameOffsetX = 0;
			int gameOffsetY = 0;
			if (config.includeFrame())
			{
				clientUi.paint(graphics);
				final Point canvasOffset = clientUi.getCanvasOffset();
				gameOffsetX = canvasOffset.getX();
				gameOffsetY = canvasOffset.getY();
			}
			graphics.drawImage(image, gameOffsetX, gameOffsetY, null);
			File playerFolder;
			if (client.getLocalPlayer() != null && client.getLocalPlayer().getName() != null)
			{
				playerFolder = new File(SCREENSHOT_DIR, client.getLocalPlayer().getName());
			}
			else
			{
				playerFolder = SCREENSHOT_DIR;
			}
			playerFolder.mkdirs();
			executor.execute(() ->
			{
				try
				{
					File screenshotFile = new File(playerFolder, fileName + ".png");
					ImageIO.write(screenshot, "PNG", screenshotFile);
					if (config.uploadScreenshot())
					{
						uploadScreenshot(screenshotFile);
					}
					else if (config.notifyWhenTaken())
					{
						notifier.notify("A screenshot was saved to " + screenshotFile, TrayIcon.MessageType.INFO);
					}
				}
				catch (IOException ex)
				{
					log.warn("error writing screenshot", ex);
				}
			});
		};
		if (config.displayDate())
		{
			screenshotOverlay.queueForTimestamp(screenshotConsumer);
		}
		else
		{
			drawManager.requestNextFrameListener(screenshotConsumer);
		}
	}
void takeScreenshot ( String fileName ) { if ( client . getGameState ( ) == GameState . LOGIN_SCREEN ) { log . info ( "Login screenshot prevented" ) ; return ; } Consumer < BufferedImage > screenshotConsumer = image -> { BufferedImage screenshot = config . includeFrame ( ) ? new BufferedImage ( clientUi . getWidth ( ) , clientUi . getHeight ( ) , BufferedImage . TYPE_INT_ARGB ) : new BufferedImage ( image . getWidth ( ) , image . getHeight ( ) , BufferedImage . TYPE_INT_ARGB ) ; Graphics graphics = screenshot . getGraphics ( ) ; int gameOffsetX = 0 ; int gameOffsetY = 0 ; if ( config . includeFrame ( ) ) { clientUi . paint ( graphics ) ; final Point canvasOffset = clientUi . getCanvasOffset ( ) ; gameOffsetX = canvasOffset . getX ( ) ; gameOffsetY = canvasOffset . getY ( ) ; } graphics . drawImage ( image , gameOffsetX , gameOffsetY , null ) ; File playerFolder ; if ( client . getLocalPlayer ( ) != null && client . getLocalPlayer ( ) . getName ( ) != null ) { playerFolder = new File ( SCREENSHOT_DIR , client . getLocalPlayer ( ) . getName ( ) ) ; } else { playerFolder = SCREENSHOT_DIR ; } playerFolder . mkdirs ( ) ; executor . execute ( ( ) -> { try { File screenshotFile = new File ( playerFolder , fileName + ".png" ) ; ImageIO . write ( screenshot , "PNG" , screenshotFile ) ; if ( config . uploadScreenshot ( ) ) { uploadScreenshot ( screenshotFile ) ; } else if ( config . notifyWhenTaken ( ) ) { notifier . notify ( "A screenshot was saved to " + screenshotFile , TrayIcon . MessageType . INFO ) ; } } catch ( IOException ex ) { log . warn ( "error writing screenshot" , ex ) ; } } ) ; } ; if ( config . displayDate ( ) ) { screenshotOverlay . queueForTimestamp ( screenshotConsumer ) ; } else { drawManager . requestNextFrameListener ( screenshotConsumer ) ; } }
Saves a screenshot of the client window to the screenshot folder as a PNG,
 and optionally uploads it to an image-hosting service.
Saves a screenshot of the client window to the screenshot folder as a PNG and optionally uploads it to an image - hosting service .
// Prevent the screenshot from being captured // Draw the client frame onto the screenshot // Evaluate the position of the game inside the frame // Draw the game onto the screenshot