Skip to content

Commit 3971dcb

Browse files
committed
chore(fastimage): purge legacy fastXXX template clutter and sync clean native structure
1 parent 2e665a8 commit 3971dcb

6 files changed

Lines changed: 30 additions & 97 deletions

File tree

build/fastimage.dll

0 Bytes
Binary file not shown.

native/fastXXX.def

Lines changed: 0 additions & 11 deletions
This file was deleted.

native/src/fastXXX.cpp

Lines changed: 0 additions & 10 deletions
This file was deleted.

native/src/fastXXX.h

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/main/java/fastXXX/FastXXX.java

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/main/java/fastimage/FastImage.java

Lines changed: 30 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package fastimage;
22

33
import fastcore.FastCore;
4+
45
import java.awt.image.BufferedImage;
56
import java.awt.image.DataBufferInt;
67
import java.lang.reflect.Field;
@@ -10,17 +11,17 @@
1011
/**
1112
* FastImage - High-performance off-heap image processing with SIMD
1213
* acceleration.
13-
*
14+
* <p>
1415
* Stores pixel data in native memory (off-heap) outside JVM garbage collection,
1516
* providing 10-50× faster image operations than BufferedImage via SSE/AVX SIMD.
16-
*
17+
* <p>
1718
* Supported operations:
1819
* - resize (bilinear, bicubic)
1920
* - blur (gaussian)
2021
* - grayscale
2122
* - brightness/contrast adjustment
2223
* - flip horizontal/vertical
23-
*
24+
* <p>
2425
* Memory: Uses ByteBuffer.allocateDirect() - not counted in JVM heap!
2526
*/
2627
public class FastImage {
@@ -35,6 +36,9 @@ public class FastImage {
3536
private int height;
3637
private boolean disposed = false;
3738

39+
private FastImage() {
40+
}
41+
3842
/**
3943
* Create FastImage from BufferedImage (ARGB format)
4044
*/
@@ -98,8 +102,8 @@ public static FastImage fromNativeHandle(long handle, int width, int height) {
98102
* The underlying memory is NOT freed when this FastImage is disposed or resized.
99103
*
100104
* @param rawPointer 64-bit native memory address pointing to ARGB/BGRA pixels
101-
* @param width image width
102-
* @param height image height
105+
* @param width image width
106+
* @param height image height
103107
*/
104108
public static FastImage wrap(long rawPointer, int width, int height) {
105109
if (rawPointer == 0L) {
@@ -143,14 +147,11 @@ public static FastImage wrap(ByteBuffer directBuffer, int width, int height) {
143147
return wrap(address, width, height);
144148
}
145149

146-
private FastImage() {
147-
}
148-
149150
// === Core Operations ===
150151

151152
/**
152153
* Resize image using bilinear interpolation
153-
*
154+
*
154155
* @param newWidth target width
155156
* @param newHeight target height
156157
*/
@@ -206,7 +207,7 @@ public FastImage resizeAreaAverage(int newWidth, int newHeight) {
206207
/**
207208
* Fast box blur - quickest approximation.
208209
* Good for real-time effects where speed matters.
209-
*
210+
*
210211
* @param radius blur radius (0-50)
211212
*/
212213
public FastImage blurBox(float radius) {
@@ -220,7 +221,7 @@ public FastImage blurBox(float radius) {
220221
/**
221222
* Separable Gaussian blur - high quality, smooth results.
222223
* Slower than box blur but looks much better.
223-
*
224+
*
224225
* @param radius blur radius (0-50)
225226
*/
226227
public FastImage blurGaussian(float radius) {
@@ -234,7 +235,7 @@ public FastImage blurGaussian(float radius) {
234235
/**
235236
* Stack blur - CSS backdrop-filter quality.
236237
* Best balance of speed and quality for UI effects.
237-
*
238+
*
238239
* @param radius blur radius (0-100)
239240
*/
240241
public FastImage blurStack(float radius) {
@@ -248,7 +249,7 @@ public FastImage blurStack(float radius) {
248249
/**
249250
* Kawase blur - multi-pass blur used by Apple/Google.
250251
* Very soft edges with configurable quality.
251-
*
252+
*
252253
* @param radius blur radius (0-50)
253254
* @param passes number of passes (1-5, higher = softer)
254255
*/
@@ -263,7 +264,7 @@ public FastImage blurKawase(float radius, int passes) {
263264
/**
264265
* Dual Kawase blur - premium 2-pass algorithm.
265266
* Best quality with excellent performance.
266-
*
267+
*
267268
* @param radius blur radius (0-50)
268269
*/
269270
public FastImage blurDualKawase(float radius) {
@@ -276,7 +277,7 @@ public FastImage blurDualKawase(float radius) {
276277
/**
277278
* Mipmapped blur - for very large blur radii (100+).
278279
* Uses downscaling + small blur + upscaling.
279-
*
280+
*
280281
* @param radius blur radius (0-200)
281282
*/
282283
public FastImage blurMipmapped(float radius) {
@@ -297,7 +298,7 @@ public FastImage grayscale() {
297298

298299
/**
299300
* Adjust brightness
300-
*
301+
*
301302
* @param factor 0.0 = black, 1.0 = unchanged, 2.0 = double brightness
302303
*/
303304
public FastImage adjustBrightness(float factor) {
@@ -309,7 +310,7 @@ public FastImage adjustBrightness(float factor) {
309310

310311
/**
311312
* Adjust contrast
312-
*
313+
*
313314
* @param factor 0.0 = gray, 1.0 = unchanged, 2.0 = double contrast
314315
*/
315316
public FastImage adjustContrast(float factor) {
@@ -339,7 +340,7 @@ public FastImage flipVertical() {
339340

340341
/**
341342
* Crop image to region (creates new FastImage, leaves original)
342-
*
343+
*
343344
* @param x left coordinate
344345
* @param y top coordinate
345346
* @param w width
@@ -384,6 +385,17 @@ public int[] getPixels() {
384385
return pixels;
385386
}
386387

388+
/**
389+
* Free native memory
390+
*/
391+
public void dispose() {
392+
if (!disposed && nativeHandle != 0) {
393+
nativeDispose(nativeHandle);
394+
nativeHandle = 0;
395+
disposed = true;
396+
}
397+
}
398+
387399
// === Getters ===
388400

389401
public int getWidth() {
@@ -402,17 +414,6 @@ public long getNativeHandle() {
402414
return nativeHandle;
403415
}
404416

405-
/**
406-
* Free native memory
407-
*/
408-
public void dispose() {
409-
if (!disposed && nativeHandle != 0) {
410-
nativeDispose(nativeHandle);
411-
nativeHandle = 0;
412-
disposed = true;
413-
}
414-
}
415-
416417

417418
private void checkDisposed() {
418419
if (disposed)

0 commit comments

Comments
 (0)