What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Some links on this page are affiliate links: if you buy through them we may earn a commission, at no extra cost to you.
Use Robot.createScreenCapture(Rectangle) to capture the same screen region in the baseline and current UI, verify that both images have identical dimensions, then compare corresponding pixels. Exact ARGB equality is appropriate when the operating system, display scale, fonts, and application state are controlled. If rendering can vary, define a per-channel tolerance or an allowed changed-pixel percentage yourself; Java does not provide a universal visual-diff threshold.
What the comparison actually measures
Robot.createScreenCapture(Rectangle) returns a BufferedImage containing pixels read from a rectangle in screen coordinates. You are comparing a raster, not the semantic contents of controls or text. The same window can produce different pixels when its position, display scaling, font rasterizer, theme, animation state, or data changes.
A reliable test therefore fixes the capture rectangle and UI state, captures only after the application is ready, and records enough diagnostic information to explain a failure. The ordinary capture does not include the mouse cursor. A nonempty rectangle is required: a zero or negative width or height causes IllegalArgumentException.
Free tools Windows power users keep installed
One-click scans. No signup required.
Exact pixel comparison: a complete Java example
The following program loads a baseline image, captures the same desktop rectangle, checks dimensions before indexing, and fails on the first differing pixel count. It uses only Java desktop APIs.
#1 Best Overall
- CRISP CLARITY: This 23.8″ Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
- WORK SEAMLESSLY: This sleek monitor is virtually bezel-free on three sides, so the screen looks even bigger for the viewer. This minimalistic design also allows for seamless multi-monitor setups that enhance your workflow and boost productivity
- A BETTER READING EXPERIENCE: For busy office workers, EasyRead mode provides a more paper-like experience for when viewing lengthy documents
import java.awt.AWTException;
import java.awt.Rectangle;
import java.awt.Robot;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public final class ScreenshotCompare {
public static void main(String[] args) throws AWTException, IOException {
if (args.length != 5) {
throw new IllegalArgumentException(
"Usage: java ScreenshotCompare baseline.png x y width height");
}
File baselineFile = new File(args[0]);
int x = Integer.parseInt(args[1]);
int y = Integer.parseInt(args[2]);
int width = Integer.parseInt(args[3]);
int height = Integer.parseInt(args[4]);
Rectangle area = new Rectangle(x, y, width, height);
BufferedImage expected = ImageIO.read(baselineFile);
if (expected == null) {
throw new IOException("No ImageIO reader could decode " + baselineFile);
}
Robot robot = new Robot();
BufferedImage actual = robot.createScreenCapture(area);
if (expected.getWidth() != actual.getWidth()
|| expected.getHeight() != actual.getHeight()) {
throw new AssertionError(String.format(
"Screenshot dimensions differ: expected %dx%d, actual %dx%d",
expected.getWidth(), expected.getHeight(),
actual.getWidth(), actual.getHeight()));
}
long differingPixels = 0;
int firstX = -1;
int firstY = -1;
for (int yy = 0; yy < expected.getHeight(); yy++) {
for (int xx = 0; xx < expected.getWidth(); xx++) {
if (expected.getRGB(xx, yy) != actual.getRGB(xx, yy)) {
differingPixels++;
if (firstX < 0) {
firstX = xx;
firstY = yy;
}
}
}
}
if (differingPixels != 0) {
throw new AssertionError(String.format(
"Found %d differing pixels; first difference at (%d,%d)",
differingPixels, firstX, firstY));
}
System.out.println("Screenshots match exactly");
}
}
Compile and run it on a desktop session, for example:
javac ScreenshotCompare.java
java ScreenshotCompare baseline.png 100 80 1200 800
ImageIO.read(File) decodes supported formats into a BufferedImage. A null result means no registered reader recognized the input; I/O errors and unsupported formats should be reported rather than treated as a matching image.
Why dimensions must be checked first
BufferedImage.getRGB(x, y) addresses a particular pixel coordinate. If width or height differs, the coordinates no longer describe the same physical region. Common causes include a changed window size, a different monitor, or a different user-space/device-pixel scale. Fail with a clear message, as the example does; do not silently compare only the overlapping area. If normalization is intentional, resize both images with a documented algorithm and accept that interpolation changes pixel values.
Recommended Free Tools
Choose a comparison policy deliberately
| Policy | Use it when | Trade-off |
|---|---|---|
| Exact pixel equality | Rendering environment and state are controlled and every changed pixel is a failure. | Any antialiasing, font, or color variation fails. |
| Per-channel tolerance | Small RGB variations should be ignored. | You must justify a channel delta and decide how alpha is handled. |
| Changed-pixel count or percentage | A small, known amount of noise is acceptable. | You need an explicit allowed count or ratio; a percentage can hide a concentrated defect. |
| Perceptual metric | Visual similarity matters more than identical raster values. | Requires another algorithm or library and a calibrated project threshold; Robot itself selects none. |
Per-channel tolerance example
getRGB returns default ARGB values in sRGB form, with 8-bit precision per component. To ignore tiny color changes, unpack red, green, and blue and mark a pixel changed when any channel exceeds a project-owned delta. The following method also lets you choose whether alpha participates:
Rank #2
- CRISP CLARITY: This 22 inch class (21.5″ viewable) Philips V line monitor delivers crisp Full HD 1920x1080 visuals. Enjoy movies, shows and videos with remarkable detail
- 100HZ FAST REFRESH RATE: 100Hz brings your favorite movies and video games to life. Stream, binge, and play effortlessly
- SMOOTH ACTION WITH ADAPTIVE-SYNC: Adaptive-Sync technology ensures fluid action sequences and rapid response time. Every frame will be rendered smoothly with crystal clarity and without stutter
- INCREDIBLE CONTRAST: The VA panel produces brighter whites and deeper blacks. You get true-to-life images and more gradients with 16.7 million colors
- THE PERFECT VIEW: The 178/178 degree extra wide viewing angle prevents the shifting of colors when viewed from an offset angle, so you always get consistent colors
static boolean differs(int expectedArgb, int actualArgb,
int channelDelta, boolean compareAlpha) {
int ea = (expectedArgb >>> 24) & 0xff;
int er = (expectedArgb >>> 16) & 0xff;
int eg = (expectedArgb >>> 8) & 0xff;
int eb = expectedArgb & 0xff;
int aa = (actualArgb >>> 24) & 0xff;
int ar = (actualArgb >>> 16) & 0xff;
int ag = (actualArgb >>> 8) & 0xff;
int ab = actualArgb & 0xff;
if (Math.abs(er - ar) > channelDelta
|| Math.abs(eg - ag) > channelDelta
|| Math.abs(eb - ab) > channelDelta) {
return true;
}
return compareAlpha && Math.abs(ea - aa) > channelDelta;
}
Use it inside the same dimension-checked loop, count changed pixels, and compare that count (or its fraction of total pixels) with a threshold documented by your project. Calibrate the rule against known intentional changes and expected rendering variation; do not copy an unexplained number from another test suite. Baseline and screen images can also use different alpha conventions, so decide explicitly whether alpha matters.
Capture rectangles, monitors, and high-DPI displays
Screen coordinates
The rectangle is expressed in screen coordinates. With multiple monitors, the desktop may use a shared virtual coordinate space or device-specific coordinate spaces depending on the platform configuration. Record which display and origin your test uses, and keep the window on that display.
Scaling and multi-resolution capture
On a high-resolution display, user-space coordinates can map to device pixels. Java provides createMultiResolutionScreenCapture, whose result can contain a scaled base image and a native-device-resolution variant. Compare images at the same resolution and edge placement; comparing a scaled baseline with a native capture guarantees dimension and pixel differences. A practical diagnostic is to log the image dimensions produced by every capture.
Stable regions and masks
Clocks, caret blinking, animated canvases, video, notifications, and randomized content are intentionally dynamic. Either wait for a deterministic state, mask those rectangles before comparison, or compare only a stable element. A mask is a test-policy decision, not behavior supplied by Robot; keep it in source control with the reason for each excluded region.
Rank #3
- Clear visuals. Fluid motion: A 144Hz refresh rate and 1ms MPRT deliver smooth, tear‑free motion across work, gaming, and streaming for clearer, more fluid viewing.
- Eye comfort: TÜV Rheinland 3‑star* certification reduces harmful blue light while preserving stunning color quality without compromise. *TÜV Rheinland 3-star eye comfort certification.
- Wide viewing angle: Get consistent views across a wide 178° /178° viewing angle.
- In-Plane Switching (IPS): See excellent color accuracy and consistency across wide viewing angles with In-plane Switching (IPS) technology.
- Ultra-thin bezels: Maximize your viewing experience with thin bezels.
Synchronize the UI before capturing
Capture can take time, and Oracle advises against performing it on the AWT Event Dispatch Thread. Run the capture from a worker or test thread so repaint and input processing are not blocked. More importantly, synchronize on an observable ready condition: wait until a required component is visible, a loading indicator disappears, or your test state reports completion. A fixed sleep can work for a controlled demo but is fragile under a busy machine or variable network.
Take the baseline and current images with the same window position, size, theme, font installation, locale, display scale, and application data. If you cannot control those variables, prefer a tolerance or a focused-region comparison and make the remaining variability visible in the report.
Permissions and failure modes
SecurityExceptionor unusable pixels: the operating system or desktop session may restrict screen capture. Grant the desktop-capture permission appropriate to the platform, run in an interactive session, and fail the test as an environment problem rather than accepting the image.IllegalArgumentException: width or height is zero or negative. Validate rectangle arguments before constructing or capturing.- Dimension mismatch: window geometry, monitor selection, or DPI scaling changed. Log rectangle coordinates and image dimensions, then restore the known display setup.
- All pixels differ after a harmless change: check color profile, scaling, font rendering, theme, and alpha policy before raising a threshold.
- Intermittent differences: look for animation, timers, asynchronous network data, caret blinking, or an unfinished repaint. Synchronize on state and capture off the event-dispatch thread.
ImageIO.readreturnsnull: the file format has no registered reader. Use a supported format or install/register an appropriate ImageIO plugin and report decode errors.- Useful failure output is missing: save the actual image, a visual diff, changed-pixel count, first differing coordinate, rectangle, display scale, and test state. Those are implementation choices, but they reduce diagnosis time dramatically.
When Java Robot is the wrong layer
Robot observes the physical desktop, so it is suitable for end-to-end checks involving native windows, menus, focus, and compositor output. It is a poor fit when you only need a web page image, a component’s DOM state, or a repeatable server-side render. Browser automation can capture a page at a controlled viewport; component tests can assert structure without raster noise. Choose the narrowest layer that proves the behavior you care about, and reserve full-screen comparisons for defects that truly appear in the rendered desktop.
Or skip the browser setup
If your target is a web page rather than a native desktop surface, ScreenshotNeo returns a PNG, JPEG, WebP, or PDF from one HTTP request. It removes cookie/consent banners, newsletter popups, and chat widgets before capture; bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers report the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other MCP clients. Every plan includes the features, with 63 capture options such as full-page lazy-image loading, CSS-selector element capture, device presets, dark mode, custom CSS/JavaScript, waits, request blocking, cookies and headers, geolocation, PDF controls, caching, signed links, webhooks, bulk capture, and a usage API.
cURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
See the complete parameter reference in the ScreenshotNeo documentation. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots. Create a free ScreenshotNeo account.
Rank #4
- CURVED FOR ENHANCED ENGAGEMENT: An immersive viewing experience with a curved monitor that wraps more closely around your field of vision; It creates a wider view, enhancing depth perception and minimizing peripheral distraction
- SMOOTH PERFORMANCE FOR SEAMLESS CONTENT: Stay in the action when playing games, watching videos, or working on creative projects; The 100Hz refresh rate reduces lag and motion blur so you don't miss a thing in fast-paced moments¹
- MORE GAMING POWER: Gain the edge with optimizable game settings; Color and image contrast can be adjusted to see scenes more vividly and spot enemies hiding in the dark; Game Mode adjusts any game to fill the screen so you can view every detail²
- KEEP IT EASY ON THE EYES: Care for your eyes and stay comfortable, even during long sessions; Advanced eye comfort technology certified by TÜV reduces eye strain by minimizing blue light and reducing irritating screen flicker²
- INCREASED VERSATILITY: Connect to more; Plug devices straight into your monitor for increased flexibility, making your computing environment even more convenient
Cost and reliability considerations
- Local
Robotcaptures use your machine and Java desktop runtime, but their reproducibility depends on that machine’s display session and permissions. - Exact comparisons are cheap to compute but can produce noisy failures when environments drift. Tolerances reduce noise at the cost of potentially hiding small defects.
- For remote page capture, ScreenshotNeo bills only clean shots; failed loads, bot checks, blank pages, timeouts, and cache hits are free and identified by response headers. Its plans are Free (1,000/month), Starter $5/3,000, Growth $15/15,000, Pro $39/60,000, Scale $99/250,000, and Business $249/1,000,000; yearly billing gives two months free.
FAQ
Does Robot capture the mouse pointer?
No. Oracle’s API documentation states that the ordinary screen capture excludes the cursor, so test cursor behavior with a different mechanism.
Should alpha always be compared?
No. Decide based on your baseline format and test goal. Loaded files and screen captures can use different alpha conventions; document whether alpha is part of equality.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitchesCan I compare screenshots from different monitors?
Only after deliberately normalizing coordinate space and resolution. A safer policy is to capture and compare on the same monitor with the same scaling configuration.
Is there an Oracle-recommended tolerance value?
No. Oracle documents capture and pixel access, not a universal RGB delta or changed-pixel percentage. Your project must calibrate and justify its own rule.
Best Value
- 【INTEGRATED SPEAKERS】Whether you're at work or in the midst of an intense gaming session, our built-in speakers provide rich and seamless audio, all while keeping your desk clutter-free.
- 【EASY ON THE EYES】 Protect your eyes and enhance your comfort with Blue-Light Shift technology. This feature reduces harmful blue light emissions from your screen, helping to alleviate eye strain during long hours of use and promoting healthier viewing habits.
- 【WIDEN YOUR PERSPECTIVE】Our sleek minimal bezel design ensures undivided attention. The nearly bezel-free display seamlessly connects in a dual monitor arrangement, delivering an unobstructed view that lets you focus on more at once, completely distraction-free.
Frequently Asked Questions
Can Robot compare screenshots without writing image files?
Yes. Keep the baseline as a BufferedImage (or load it once) and compare it directly with the BufferedImage returned by createScreenCapture; files are only needed for persistence and diagnostics.
Why do screenshots differ even when the UI looks identical?
Subpixel antialiasing, font versions, display scaling, color conversion, animation timing, and alpha representation can change raster values while preserving the apparent layout.
The Bottom Line
For deterministic desktop tests, capture the identical rectangle, verify dimensions, and compare pixels under an explicit policy. Stabilize DPI, state, timing, and permissions first; only then add a documented tolerance or mask for variation you intentionally accept.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

