Class PatternScaler
java.lang.Object
io.github.jspinak.brobot.util.image.PatternScaler
Utility for scaling pattern images to handle DPI and resolution differences.
This utility is particularly useful for:
- Handling DPI scaling differences between development and production environments
- Pre-scaling patterns for better performance compared to runtime scaling
- Creating pattern variants for different screen resolutions
- Testing pattern matching at different scales
The scaler preserves image quality using bilinear interpolation and anti-aliasing, ensuring that scaled patterns maintain their matching characteristics.
- Since:
- 1.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImage
scaleImage
(BufferedImage image, float scaleFactor) Scales a BufferedImage by the given factor.static void
scalePatterns
(String sourceDir, float scaleFactor, String suffix) Scales all PNG patterns in a directory and saves them with a suffix.static void
scalePatterns
(String sourceDir, String targetDir, float scaleFactor, String suffix) Scales all PNG patterns in a directory and saves them in a target directory.
-
Constructor Details
-
PatternScaler
public PatternScaler()
-
-
Method Details
-
scalePatterns
Scales all PNG patterns in a directory and saves them with a suffix.- Parameters:
sourceDir
- The directory containing pattern imagesscaleFactor
- The scale factor (e.g., 0.8 for 80%, 1.25 for 125%)suffix
- The suffix to append to scaled files (e.g., "-80", "-125")
-
scalePatterns
public static void scalePatterns(String sourceDir, String targetDir, float scaleFactor, String suffix) Scales all PNG patterns in a directory and saves them in a target directory.- Parameters:
sourceDir
- The directory containing pattern imagestargetDir
- The directory to save scaled imagesscaleFactor
- The scale factor (e.g., 0.8 for 80%, 1.25 for 125%)suffix
- Optional suffix to append to scaled files (can be null)
-
scaleImage
Scales a BufferedImage by the given factor.- Parameters:
image
- The image to scalescaleFactor
- The scale factor- Returns:
- The scaled image
-