Package com.digitizer.image
Class ImageLoader
java.lang.Object
com.digitizer.image.ImageLoader
Utility class for loading images from disk.
Prefer loadImage(File) which first tries JavaFX's Image
to read common formats (PNG/JPG/BMP) and falls back to ImageIO
for extended formats (TIFF, WebP). The utility also contains convenience
methods for obtaining image dimensions.
-
Method Summary
Modifier and TypeMethodDescriptionstatic intgetImageHeight(javafx.scene.image.Image image) Gets the height of an image in pixels.static intgetImageWidth(javafx.scene.image.Image image) Gets the width of an image in pixels.static javafx.scene.image.ImageLoads an image from the specified file.static javafx.scene.image.ImageLoads an image from the specified file path.
-
Method Details
-
loadImage
Loads an image from the specified file.- Parameters:
file- the image file (PNG, JPEG, BMP, TIFF, WebP, etc.)- Returns:
- the loaded JavaFX Image
- Throws:
IOException- if the file cannot be read or is not a valid image
-
loadImage
Loads an image from the specified file path.- Parameters:
filePath- the path to the image file- Returns:
- the loaded JavaFX Image
- Throws:
IOException- if the file cannot be read or is not a valid image
-
getImageWidth
public static int getImageWidth(javafx.scene.image.Image image) Gets the width of an image in pixels.- Parameters:
image- the image- Returns:
- the width, or 0 if image is null
-
getImageHeight
public static int getImageHeight(javafx.scene.image.Image image) Gets the height of an image in pixels.- Parameters:
image- the image- Returns:
- the height, or 0 if image is null
-