Package dev.brachtendorf.graphics
Class ImageUtil
- java.lang.Object
-
- dev.brachtendorf.graphics.ImageUtil
-
public class ImageUtil extends Object
- Author:
- Kilian
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImageUtil.BImageTypeBuffered image types mapped to enum values for easier handling
-
Constructor Summary
Constructors Constructor Description ImageUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BufferedImagecreateThumbnail(BufferedImage image, int newWidth, int newHeight)Returns a thumbnail of a source image.static javafx.scene.paint.ColordominantColor(BufferedImage bImage)Return the dominant color of this image.static javafx.scene.paint.ColordominantColor(javafx.scene.image.Image image)Return the dominant color of this image.static BufferedImagegetScaledInstance(BufferedImage source, int width, int height)Resize the buffered image to an arbitrary dimensionstatic javafx.scene.paint.ColorinterpolateColor(BufferedImage bImage)Calculate the interpolated average color of the imagestatic javafx.scene.paint.ColorinterpolateColor(javafx.scene.image.Image image)Calculate the interpolated average color of the imagestatic javafx.scene.paint.ColormeanColor(BufferedImage image)Calculate the average color of this image.static javafx.scene.paint.ColormeanColor(javafx.scene.image.Image image)Calculate the average color of this image.static BufferedImagetoNewType(BufferedImage original, int newType)Convert the image to an image of the new typestatic BufferedImagetoNewType(BufferedImage original, ImageUtil.BImageType newType)Convert the image to an image of the new type
-
-
-
Method Detail
-
getScaledInstance
public static BufferedImage getScaledInstance(BufferedImage source, int width, int height)
Resize the buffered image to an arbitrary dimensionIf a high quality interpolated thumbnail is required
createThumbnail(BufferedImage, int, int)may be more suited.- Parameters:
source- the source imagewidth- the new widthheight- the new height- Returns:
- the resized image
- Since:
- 1.0.0 com.github.kilianB, 1.4.2 fixed not using awt rescale com.github.kilianB, 1.5.3 fixed using ImageTypeSpecifier to create compatible images for custom type com.github.kilianB
-
createThumbnail
public static BufferedImage createThumbnail(BufferedImage image, int newWidth, int newHeight)
Returns a thumbnail of a source image.
TODO LGPL LICENSE!!- Parameters:
image- the source imagenewWidth- the width of the thumbnailnewHeight- the height of the thumbnail- Returns:
- a new compatible
BufferedImagecontaining a thumbnail ofimage - Throws:
IllegalArgumentException- ifnewWidthis larger than the width ofimageor ifnewHeightis larger than the height ofimage or if one the dimensions is not > 0@ since 1.5.0
-
toNewType
public static BufferedImage toNewType(BufferedImage original, int newType)
Convert the image to an image of the new type- Parameters:
original- the original image to convertnewType- the new type- Returns:
- a copy of the original image with new pixel type
-
toNewType
public static BufferedImage toNewType(BufferedImage original, ImageUtil.BImageType newType)
Convert the image to an image of the new type- Parameters:
original- the original image to convertnewType- the new type- Returns:
- a copy of the original image with new pixel type
-
interpolateColor
public static javafx.scene.paint.Color interpolateColor(javafx.scene.image.Image image)
Calculate the interpolated average color of the image- Parameters:
image- the source image- Returns:
- the average color of the image
- Since:
- 1.0.0 com.github.kilianB
-
interpolateColor
public static javafx.scene.paint.Color interpolateColor(BufferedImage bImage)
Calculate the interpolated average color of the image- Parameters:
bImage- the source image- Returns:
- the average color of the image
- Since:
- 2.0.1
-
dominantColor
public static javafx.scene.paint.Color dominantColor(BufferedImage bImage)
Return the dominant color of this image. The dominant color is the color that most often occurred in this image. Be aware that calculating the average color using this approach is a rather expensive operation.- Parameters:
bImage- The source image- Returns:
- the dominant color of this image
- Since:
- 2.0.1
-
dominantColor
public static javafx.scene.paint.Color dominantColor(javafx.scene.image.Image image)
Return the dominant color of this image. The dominant color is the color that most often occurred in this image. Be aware that calculating the average color using this approach is a rather expensive operation.- Parameters:
image- The source image- Returns:
- the dominant color of this image
- Since:
- 1.0.0 com.github.kilianB
-
meanColor
public static javafx.scene.paint.Color meanColor(BufferedImage image)
Calculate the average color of this image. The average color is determined by summing the squared argb component of each pixel and determining the mean value of these.- Parameters:
image- The source image- Returns:
- The average mean color of this image
- Since:
- 2.0.1
-
meanColor
public static javafx.scene.paint.Color meanColor(javafx.scene.image.Image image)
Calculate the average color of this image. The average color is determined by summing the squared argb component of each pixel and determining the mean value of these.- Parameters:
image- The source image- Returns:
- The average mean color of this image
- Since:
- 1.0.0 com.github.kilianB
-
-