SudokuFX
Loading...
Searching...
No Matches
fr.softsf.sudokufx.common.util.ImageUtils Class Reference

Utility class providing helper methods for common image-related operations in JavaFX. More...

+ Collaboration diagram for fr.softsf.sudokufx.common.util.ImageUtils:

Public Member Functions

BackgroundImage createBackgroundImage (Image resizedImage)
 Creates a JavaFX BackgroundImage from the provided image.
 
ImageMeta getImageMeta (File file)
 Reads image metadata (width, height) and calculates the scale factor needed to resize the image so it fits within a predefined grid pane area (3 times the visual width and height), without fully loading the image in memory.
 
Color intToColor (int colorValue)
 Converts a 32-bit integer color value in the format 0xRRGGBBAA into a JavaFX Color object.
 
boolean isValidImage (File file)
 Determines if the given file has a supported image extension.
 

Static Private Attributes

static final double ALPHA_NORMALIZATION = 255.0
 
static final int ALPHA_SHIFT = 0
 
static final int BLUE_SHIFT = 8
 
static final int BYTE_MASK = 0xFF
 
static final int GREEN_SHIFT = 16
 
static final Logger LOG = LoggerFactory.getLogger(ImageUtils.class)
 
static final int RED_SHIFT = 24
 

Detailed Description

Utility class providing helper methods for common image-related operations in JavaFX.

Includes support for:

  • Converting 32-bit integer colors to JavaFX Color
  • Validating image file formats
  • Calculating scale factors to resize images to fit layout constraints
  • Creating BackgroundImage instances with custom layout properties

All methods throw IllegalArgumentException when passed null arguments.

This class is not instantiable and is intended to be used statically.

Member Function Documentation

◆ createBackgroundImage()

BackgroundImage fr.softsf.sudokufx.common.util.ImageUtils.createBackgroundImage ( Image resizedImage)

Creates a JavaFX BackgroundImage from the provided image.

The background image is centered, non-repeating, and sized to one-third of the original image's width and height.

Parameters
resizedImagethe image to use as the background; must not be null
Returns
a BackgroundImage configured with the given image
Exceptions
IllegalArgumentExceptionif resizedImage is null

◆ getImageMeta()

ImageMeta fr.softsf.sudokufx.common.util.ImageUtils.getImageMeta ( File file)

Reads image metadata (width, height) and calculates the scale factor needed to resize the image so it fits within a predefined grid pane area (3 times the visual width and height), without fully loading the image in memory.

Parameters
filethe image file; must not be null
Returns
ImageMeta containing width, height and scaleFactor
Exceptions
IllegalArgumentExceptionif file is null, cannot be opened as image stream, has unsupported format, invalid structure, or zero dimensions
UncheckedIOExceptionif an I/O error occurs while reading the image file
+ Here is the call graph for this function:

◆ intToColor()

Color fr.softsf.sudokufx.common.util.ImageUtils.intToColor ( int colorValue)

Converts a 32-bit integer color value in the format 0xRRGGBBAA into a JavaFX Color object.

Parameters
colorValueThe color as an integer in hexadecimal format (0xRRGGBBAA).
Returns
A Color instance representing the given color and alpha.

◆ isValidImage()

boolean fr.softsf.sudokufx.common.util.ImageUtils.isValidImage ( File file)

Determines if the given file has a supported image extension.

Accepted formats: JPG, JPEG, PNG, BMP (case-insensitive).

Parameters
filethe file to check; must not be null
Returns
true if the file has a valid image extension; false otherwise
Exceptions
IllegalArgumentExceptionif file is null

Member Data Documentation

◆ ALPHA_NORMALIZATION

final double fr.softsf.sudokufx.common.util.ImageUtils.ALPHA_NORMALIZATION = 255.0
staticprivate

◆ ALPHA_SHIFT

final int fr.softsf.sudokufx.common.util.ImageUtils.ALPHA_SHIFT = 0
staticprivate

◆ BLUE_SHIFT

final int fr.softsf.sudokufx.common.util.ImageUtils.BLUE_SHIFT = 8
staticprivate

◆ BYTE_MASK

final int fr.softsf.sudokufx.common.util.ImageUtils.BYTE_MASK = 0xFF
staticprivate

◆ GREEN_SHIFT

final int fr.softsf.sudokufx.common.util.ImageUtils.GREEN_SHIFT = 16
staticprivate

◆ LOG

final Logger fr.softsf.sudokufx.common.util.ImageUtils.LOG = LoggerFactory.getLogger(ImageUtils.class)
staticprivate

◆ RED_SHIFT

final int fr.softsf.sudokufx.common.util.ImageUtils.RED_SHIFT = 24
staticprivate

The documentation for this class was generated from the following file: