Class PatternScaler

java.lang.Object
io.github.jspinak.brobot.util.image.PatternScaler

public class PatternScaler extends Object
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 Details

    • PatternScaler

      public PatternScaler()
  • Method Details

    • scalePatterns

      public static void scalePatterns(String sourceDir, float scaleFactor, String suffix)
      Scales all PNG patterns in a directory and saves them with a suffix.
      Parameters:
      sourceDir - The directory containing pattern images
      scaleFactor - 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 images
      targetDir - The directory to save scaled images
      scaleFactor - 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

      public static BufferedImage scaleImage(BufferedImage image, float scaleFactor)
      Scales a BufferedImage by the given factor.
      Parameters:
      image - The image to scale
      scaleFactor - The scale factor
      Returns:
      The scaled image