Skip to content

andrestubbe/FastScreen

Repository files navigation

FastScreen — High-Performance Java Screen Capture

⚡ Ultra-fast Java screen capture library — 500-2000 FPS zero-copy capture

Build Java Platform License: MIT JitPack

Keywords: fastjava, java screen capture, java screenshot, directx screen capture, dxgi desktop duplication, zero copy capture, high fps screen capture, java vision, computer vision java, gpu screen capture

FastScreen is a high-performance Java screen capture library and part of the FastJava ecosystem. It uses DXGI Desktop Duplication API for zero-copy, hardware-accelerated screen capture at 500-2000 FPS. Built for computer vision, gaming bots, screen recording, and real-time monitoring applications.

If you need high-FPS screen capture without the 50-100ms latency of java.awt.Robot, FastScreen delivers native-level performance with Java simplicity. Part of the FastJava ecosystem — Making the JVM faster.


Quick Start

Installation

Maven:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

<dependency>
    <groupId>com.github.andrestubbe</groupId>
    <artifactId>fastscreen</artifactId>
    <version>v1.0.0</version>
</dependency>

Gradle:

repositories {
    maven { url 'https://jitpack.io' }
}

dependencies {
    implementation 'com.github.andrestubbe:fastscreen:v1.0.0'
}

Direct Download (both required):

# Run with both JARs
java -cp "fastscreen-1.0.0.jar:fastcore-1.0.0.jar:." YourApp

Basic Usage

import fastscreen.FastScreen;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;

FastScreen screen = new FastScreen();

// Single screenshot - 10-17× faster than Robot
BufferedImage screenshot = screen.captureScreen(new Rectangle(0, 0, 1920, 1080));

// Or get raw pixel array (zero-copy)
int[] pixels = screen.captureRaw(0, 0, 1920, 1080);

High-FPS Streaming

// Start 60fps-240fps streaming capture
screen.startStream(0, 0, 1920, 1080);

while (true) {
    if (screen.hasNewFrame()) {
        int[] pixels = screen.getNextFrame(); // RGBA pixel array
        double fps = screen.getStreamFPS();
        System.out.println("Streaming at " + fps + " FPS");
    }
}

Key Features

  • 500-2000 FPS capture — Zero-copy DXGI Desktop Duplication
  • 10-17× faster than java.awt.Robot (8-16ms vs 50-100ms)
  • Hardware acceleration — GPU to CPU without memory copy
  • Zero GC pressure — Native buffers, reusable arrays
  • Multiple outputs — BufferedImage, raw pixels, or stream callback
  • Powered by FastCore — Unified JNI loader for all FastJava modules
  • MIT licensed — free for commercial use

Performance Benchmarks

Measure yourself — run the included benchmark:

cd examples/03-benchmark
mvn compile exec:java

Expected improvements (your hardware may vary):

  • Single capture: 10-50× faster than java.awt.Robot
  • Streaming: 60-240fps depending on GPU and resolution
  • Zero GC pressure with native buffers

See examples/03-benchmark for detailed measurement.


Examples

All examples are in the examples/ folder:

# Basic screenshot demo
cd examples/00-basic-capture
mvn compile exec:java

# High-FPS streaming demo
cd examples/01-streaming
cd examples/02-vision-pipeline

Project Structure

fastscreen/
├── src/main/java/fastscreen/     # Main API
│   └── FastScreen.java           # Core capture class
├── examples/                     # Runnable examples
│   ├── 00-basic-capture/         # Simple screenshot
│   ├── 01-streaming/             # High-FPS demo
│   └── 02-vision-pipeline/       # CV integration
├── native/                       # C++ JNI source
│   ├── fastscreen.cpp            # JNI wrapper
│   └── DXGICapture.cpp           # DirectX capture
├── pom.xml                       # Maven configuration
├── README.md                     # This file
└── COMPILE.md                    # Build instructions

Building from Source

Prerequisites

  • JDK 17+
  • Maven 3.9+
  • Visual Studio 2019+ (for native DLL)
  • Windows 10/11 SDK

Build

git clone https://github.com/andrestubbe/fastscreen.git
cd fastscreen

# Build Java + native DLL
mvn clean compile

# Create JAR with native libraries
mvn package

API Reference

Screen Capture

  • captureScreen(Rectangle rect) — BufferedImage screenshot
  • captureRaw(int x, int y, int w, int h) — Raw RGBA pixel array
  • getPixelColor(int x, int y) — Single pixel (fast)

Streaming (High-FPS)

  • startStream(int x, int y, int w, int h) — Begin capture stream
  • hasNewFrame() — Check for new frame available
  • getNextFrame() — Get next frame (non-blocking)
  • stopStream() — Stop and cleanup
  • getStreamFPS() — Current capture FPS

Monitor Selection

  • getMonitorCount() — Number of displays
  • captureMonitor(int index) — Capture specific monitor

Architecture

Java API (FastScreen.java)
    ↓ JNI (via FastCore)
Native Layer (C++/Win32)
    └── DXGI Desktop Duplication API
        └── Direct GPU framebuffer access
    ↓
Windows OS (Hardware)

Powered by FastCore — Unified JNI loader for the FastJava ecosystem.


Platform Support

Platform Status
Windows 11 ✅ Full support
Windows 10 ✅ Full support
Linux ❌ Not planned (no DXGI)
macOS ❌ Not planned (no DXGI)

Version History

v1.0.0 — Current

  • DXGI Desktop Duplication API — hardware-accelerated capture
  • Zero-copy streaming — 500-2000 FPS
  • FastCore integration — Unified JNI loader
  • Multiple output formats — BufferedImage, raw pixels

License

MIT License — free for commercial and private use. See LICENSE for details.


Part of FastJava Ecosystem

Module Purpose Link
FastCore JNI loader GitHub
FastRobot Input automation GitHub
FastVision GPU vision pipeline GitHub
FastImage Image processing GitHub
FastGraphics GPU rendering GitHub

License

MIT License — See LICENSE for details.


FastScreenHigh-performance Java screen capture.

Part of the FastJava Ecosystemgithub.com/andrestubbe
Making the JVM faster through native acceleration.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors