Skip to content

Commit 8403791

Browse files
committed
Standardize: add LICENSE, .gitignore, update README, clean files
1 parent bfd774a commit 8403791

28 files changed

Lines changed: 948 additions & 31 deletions

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,16 @@ Thumbs.db
4444
# Test outputs
4545
test-output/
4646
benchmark_results/
47+
48+
# IntelliJ IDEA
49+
.idea/
50+
*.iml
51+
*.ipr
52+
*.iws
53+
54+
# Release files (local only)
55+
RELEASE.txt
56+
RELEASEV*.md
57+
58+
# TODO files (local only)
59+
TODO.md

FastBlurAnimation.java

Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
import fastimage.FastImage;
2+
import javax.swing.*;
3+
import java.awt.*;
4+
import java.awt.image.BufferedImage;
5+
6+
/**
7+
* Optimierte Blur-Animation:
8+
* - Bild wird vorher kleiner resized (Performance!)
9+
* - Kein dispose/create pro Frame (wiederverwendet)
10+
* - Direkte Pixel-Manipulation statt ToBufferedImage
11+
*/
12+
public class FastBlurAnimation extends JFrame implements Runnable {
13+
14+
private BufferedImage originalSmall; // Kleines Bild für Performance
15+
private FastImage fastImage;
16+
private JLabel imageLabel;
17+
private volatile boolean running = true;
18+
private float currentRadius = 0f;
19+
private long startTime;
20+
21+
private static final float MIN_RADIUS = 0.0f;
22+
private static final float MAX_RADIUS = 15.0f;
23+
private static final float CYCLE_MS = 3000f; // 3 Sekunden = schneller
24+
private static final int TARGET_SIZE = 400; // Max 400px = viel schneller!
25+
26+
public FastBlurAnimation(BufferedImage original) {
27+
super("Fast Blur Animation - Optimized");
28+
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
29+
30+
// BILD VORHER KLEINER MACHEN (CRUCIAL!)
31+
int w = original.getWidth();
32+
int h = original.getHeight();
33+
int maxDim = Math.max(w, h);
34+
35+
if (maxDim > TARGET_SIZE) {
36+
double scale = (double)TARGET_SIZE / maxDim;
37+
w = (int)(w * scale);
38+
h = (int)(h * scale);
39+
System.out.println("[OPTIMIZED] Resizing to " + w + "x" + h + " for performance");
40+
41+
// Schneller Resize mit FastImage
42+
FastImage temp = FastImage.fromBufferedImage(original);
43+
temp.resize(w, h);
44+
originalSmall = temp.toBufferedImage();
45+
temp.dispose();
46+
} else {
47+
originalSmall = original;
48+
}
49+
50+
// Einmalig erstellen - wiederverwenden!
51+
fastImage = FastImage.fromBufferedImage(originalSmall);
52+
53+
imageLabel = new JLabel();
54+
imageLabel.setHorizontalAlignment(JLabel.CENTER);
55+
updateImage(originalSmall);
56+
add(imageLabel, BorderLayout.CENTER);
57+
58+
pack();
59+
// Links positionieren
60+
Dimension screen = Toolkit.getDefaultToolkit().getScreenSize();
61+
int x = (screen.width / 2) - getWidth() - 10;
62+
int y = (screen.height - getHeight()) / 2;
63+
setLocation(x, y);
64+
setVisible(true);
65+
66+
startTime = System.currentTimeMillis();
67+
new Thread(this).start();
68+
}
69+
70+
private void updateImage(BufferedImage img) {
71+
imageLabel.setIcon(new ImageIcon(img));
72+
}
73+
74+
@Override
75+
public void run() {
76+
System.out.println("[DEBUG] Animation thread started");
77+
long lastFpsUpdate = startTime;
78+
int frameCount = 0;
79+
int fps = 0;
80+
int blurCount = 0;
81+
long totalBlurTime = 0;
82+
83+
while (running) {
84+
long loopStart = System.nanoTime();
85+
long now = System.currentTimeMillis();
86+
float elapsed = now - startTime;
87+
88+
// Sinus-Welle
89+
float sin = (float)Math.sin(elapsed / CYCLE_MS * 2 * Math.PI);
90+
float norm = (sin + 1f) / 2f;
91+
float targetRadius = MIN_RADIUS + norm * (MAX_RADIUS - MIN_RADIUS);
92+
93+
// Nur updaten wenn Radius sich genug ändert
94+
if (Math.abs(targetRadius - currentRadius) > 0.2f) {
95+
currentRadius = targetRadius;
96+
blurCount++;
97+
98+
long t1 = System.nanoTime();
99+
fastImage.dispose();
100+
long t2 = System.nanoTime();
101+
fastImage = FastImage.fromBufferedImage(originalSmall);
102+
long t3 = System.nanoTime();
103+
fastImage.blur(currentRadius);
104+
long t4 = System.nanoTime();
105+
BufferedImage blurred = fastImage.toBufferedImage();
106+
long t5 = System.nanoTime();
107+
108+
long disposeMs = (t2 - t1) / 1_000_000;
109+
long createMs = (t3 - t2) / 1_000_000;
110+
long blurMs = (t4 - t3) / 1_000_000;
111+
long toBufMs = (t5 - t4) / 1_000_000;
112+
long totalMs = (t5 - t1) / 1_000_000;
113+
totalBlurTime += totalMs;
114+
115+
// Nur alle 30 frames ausgeben (nicht zu viel spam)
116+
if (blurCount % 30 == 1) {
117+
System.out.println(String.format(
118+
"[TIMING] dispose=%dms create=%dms blur=%dms toBuf=%dms TOTAL=%dms (avg=%.1fms)",
119+
disposeMs, createMs, blurMs, toBufMs, totalMs,
120+
(double)totalBlurTime / blurCount));
121+
}
122+
123+
BufferedImage blurred = fastImage.toBufferedImage();
124+
125+
final float r = currentRadius;
126+
final int ms = (int)totalMs;
127+
final int fpsFinal = fps;
128+
129+
SwingUtilities.invokeLater(() -> {
130+
updateImage(blurred);
131+
setTitle(String.format("Fast: r=%.1f t=%dms fps=%d", r, ms, fpsFinal));
132+
});
133+
}
134+
135+
frameCount++;
136+
if (now - lastFpsUpdate >= 1000) {
137+
fps = frameCount;
138+
frameCount = 0;
139+
lastFpsUpdate = now;
140+
}
141+
142+
try {
143+
Thread.sleep(8); // ~120fps target (warten auf Blur)
144+
} catch (InterruptedException e) {
145+
break;
146+
}
147+
}
148+
149+
fastImage.dispose();
150+
}
151+
152+
public static void main(String[] args) {
153+
BufferedImage img = DemoUtils.createTestImage();
154+
SwingUtilities.invokeLater(() -> new FastBlurAnimation(img));
155+
}
156+
}

README.md

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
# FastImage — High-Performance Image Processing for Java
1+
# FastImage — High-performance image processing for Java
22

33
> **SIMD-accelerated, off-heap image processing — 10-50× faster than BufferedImage**
44
>
55
> Native speed for Java: Resize, blur, grayscale, brightness with zero GC pressure
6+
>
7+
> 🚧 **ALPHA — Daily Active Development — Infrastructure in Progress** 🚧
68
79
[![Java](https://img.shields.io/badge/Java-17+-blue.svg)](https://www.java.com)
810
[![Maven](https://img.shields.io/badge/Maven-3.9+-orange.svg)](https://maven.apache.org)
@@ -27,6 +29,8 @@ BufferedImage result = img.toBufferedImage();
2729
img.dispose(); // Free native memory
2830
```
2931

32+
> **Design Philosophy:** Stream-API Pattern + Mutable State for Performance + Image Processing Pipeline Mentality. Unlike Java Streams (immutable) or BufferedImageOps (copy-heavy), FastImage uses in-place operations on native off-heap memory. This allows zero-copy chaining: `resize().blur().grayscale()` all work on the same buffer. The fluent API was dictated by the requirements: native SIMD speed requires eliminating intermediate copies.
33+
3034
---
3135

3236
## 📦 Installation
@@ -158,10 +162,14 @@ Result: Side-by-side comparison BufferedImage vs FastImage
158162

159163
| Module | Purpose | Link |
160164
|--------|---------|------|
161-
| **FastCore** | JNI loader | [GitHub](https://github.com/andrestubbe/FastCore) |
162-
| **FastGraphics** | GPU rendering | [GitHub](https://github.com/andrestubbe/FastGraphics) |
163-
| **FastRobot** | Screen capture | [GitHub](https://github.com/andrestubbe/FastRobot) |
164-
| **FastMath** | SIMD math | [GitHub](https://github.com/andrestubbe/FastMath) |
165+
| **FastCore** | JNI loader | ⚠️ Alpha |
166+
| **FastGraphics** | GPU rendering | ⚠️ Alpha |
167+
| **FastRobot** | Screen capture | ⚠️ Alpha |
168+
| **FastMath** | SIMD math | ⚠️ Alpha |
169+
| **FastImage** | SIMD image processing | ⚠️ Alpha |
170+
| **FastClipboard** | Native clipboard | ⚠️ Alpha |
171+
| **FastHotkey** | Global hotkeys | ⚠️ Alpha |
172+
| **FastTheme** | Theme detection | ⚠️ Alpha |
165173

166174
## 📚 Examples
167175

compile_and_run_gaussian.bat

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@echo off
2+
cd /d C:\Users\andre\Documents\FastJava\2026-04-15-Work-FastImage-v1.0
3+
4+
echo === Compiling FastImage.java with Gaussian ===
5+
javac -d . -cp release\fastcore-1.0.0.jar src\main\java\fastimage\FastImage.java 2>&1
6+
7+
echo === Compiling Benchmarks ===
8+
javac -cp .;release\fastcore-1.0.0.jar FastImageGaussianBench.java JavaGaussianBench.java DemoUtils.java 2>&1
9+
10+
echo === Starting Benchmark ===
11+
echo FastImage (LEFT) vs Java (RIGHT)
12+
echo Both use Separable Gaussian Blur - fair comparison
13+
echo.
14+
start "FastImage Gaussian" cmd /c "java -cp .;release\fastcore-1.0.0.jar -Djava.library.path=release FastImageGaussianBench"
15+
timeout /t 2 >nul
16+
start "Java Gaussian" cmd /c "java -cp . JavaGaussianBench"

debug_demo.bat

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
@echo off
2+
cd /d C:\Users\andre\Documents\FastJava\2026-04-15-Work-FastImage-v1.0
3+
4+
echo === STEP 1: Check DLL ===
5+
if exist "release\fastimage.dll" (
6+
echo DLL found: release\fastimage.dll
7+
) else (
8+
echo ERROR: DLL not found!
9+
copy build\fastimage.dll release\
10+
)
11+
12+
echo.
13+
echo === STEP 2: Compile FastImage ===
14+
javac -d . -cp release\fastcore-1.0.0.jar src\main\java\fastimage\FastImage.java
15+
if %ERRORLEVEL% NEQ 0 (
16+
echo ERROR: FastImage compilation failed!
17+
pause
18+
exit /b 1
19+
)
20+
echo FastImage compiled OK
21+
22+
echo.
23+
echo === STEP 3: Compile Demo ===
24+
javac -cp .;release\fastcore-1.0.0.jar FastImageKillerDemo.java DemoUtils.java
25+
if %ERRORLEVEL% NEQ 0 (
26+
echo ERROR: Demo compilation failed!
27+
pause
28+
exit /b 1
29+
)
30+
echo Demo compiled OK
31+
32+
echo.
33+
echo === STEP 4: Check class files ===
34+
dir FastImageKillerDemo.class /b
35+
dir DemoUtils.class /b
36+
37+
echo.
38+
echo === STEP 5: Start Demo ===
39+
echo If no window appears, check for Java errors below:
40+
echo.
41+
java -cp .;release\fastcore-1.0.0.jar -Djava.library.path=release FastImageKillerDemo
42+
43+
echo.
44+
echo === Demo exited ===
45+
pause

examples/00-basic-usage/output.txt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[INFO] Scanning for projects...
2+
[WARNING]
3+
[WARNING] Some problems were encountered while building the effective model for fastimage.examples:image-benchmark:jar:1.0.0
4+
[WARNING] 'dependencies.dependency.systemPath' for io.github.andrestubbe:fastimage:jar should not point at files within the project directory, ${project.basedir}/../../target/fastimage-1.0.0-SNAPSHOT.jar will be unresolvable by dependent projects @ line 36, column 25
5+
[WARNING]
6+
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
7+
[WARNING]
8+
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
9+
[WARNING]
10+
[INFO]
11+
[INFO] -----------------< fastimage.examples:image-benchmark >-----------------
12+
[INFO] Building FastImage - Performance Benchmark 1.0.0
13+
[INFO] from pom.xml
14+
[INFO] --------------------------------[ jar ]---------------------------------
15+
[INFO]
16+
[INFO] --- exec:3.1.0:java (default-cli) @ image-benchmark ---
17+
[WARNING]
18+
java.lang.ClassNotFoundException: fastimage.ImageBenchmark
19+
at org.codehaus.mojo.exec.URLClassLoaderBuilder$ExecJavaClassLoader.loadClass (URLClassLoaderBuilder.java:198)
20+
at java.lang.ClassLoader.loadClass (ClassLoader.java:490)
21+
at org.codehaus.mojo.exec.ExecJavaMojo$1.run (ExecJavaMojo.java:271)
22+
at java.lang.Thread.run (Thread.java:1474)
23+
[INFO] ------------------------------------------------------------------------
24+
[INFO] BUILD FAILURE
25+
[INFO] ------------------------------------------------------------------------
26+
[INFO] Total time: 1.144 s
27+
[INFO] Finished at: 2026-04-15T10:45:17+02:00
28+
[INFO] ------------------------------------------------------------------------
29+
[ERROR] Failed to execute goal org.codehaus.mojo:exec-maven-plugin:3.1.0:java (default-cli) on project image-benchmark: An exception occurred while executing the Java class. fastimage.ImageBenchmark -> [Help 1]
30+
[ERROR]
31+
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
32+
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
33+
[ERROR]
34+
[ERROR] For more information about the errors and possible solutions, please read the following articles:
35+
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

examples/00-basic-usage/pom.xml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,13 @@
2727
</repositories>
2828

2929
<dependencies>
30-
<!-- FastImage Library -->
30+
<!-- FastImage Library (local) -->
3131
<dependency>
32-
<groupId>com.github.andrestubbe</groupId>
32+
<groupId>io.github.andrestubbe</groupId>
3333
<artifactId>fastimage</artifactId>
34-
<version>v1.0.0</version>
34+
<version>1.0.0-SNAPSHOT</version>
35+
<scope>system</scope>
36+
<systemPath>${project.basedir}/../../target/fastimage-1.0.0-SNAPSHOT.jar</systemPath>
3537
</dependency>
3638
</dependencies>
3739

examples/01-resize/pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828

2929
<dependencies>
3030
<dependency>
31-
<groupId>com.github.andrestubbe</groupId>
31+
<groupId>io.github.andrestubbe</groupId>
3232
<artifactId>fastimage</artifactId>
33-
<version>v1.0.0</version>
33+
<version>1.0.0-SNAPSHOT</version>
34+
<scope>system</scope>
35+
<systemPath>${project.basedir}/../../target/fastimage-1.0.0-SNAPSHOT.jar</systemPath>
3436
</dependency>
3537
</dependencies>
3638

examples/02-blur/pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828

2929
<dependencies>
3030
<dependency>
31-
<groupId>com.github.andrestubbe</groupId>
31+
<groupId>io.github.andrestubbe</groupId>
3232
<artifactId>fastimage</artifactId>
33-
<version>v1.0.0</version>
33+
<version>1.0.0-SNAPSHOT</version>
34+
<scope>system</scope>
35+
<systemPath>${project.basedir}/../../target/fastimage-1.0.0-SNAPSHOT.jar</systemPath>
3436
</dependency>
3537
</dependencies>
3638

examples/03-chain/pom.xml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,11 @@
2828

2929
<dependencies>
3030
<dependency>
31-
<groupId>com.github.andrestubbe</groupId>
31+
<groupId>io.github.andrestubbe</groupId>
3232
<artifactId>fastimage</artifactId>
33-
<version>v1.0.0</version>
33+
<version>1.0.0-SNAPSHOT</version>
34+
<scope>system</scope>
35+
<systemPath>${project.basedir}/../../target/fastimage-1.0.0-SNAPSHOT.jar</systemPath>
3436
</dependency>
3537
</dependencies>
3638

0 commit comments

Comments
 (0)