Class ImageUtils
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImage
autoCropTile
(BufferedImage tile) static BufferedImage
brighten
(BufferedImage image) static ImageIcon
changeSaturation
(ImageIcon icon, float modifier) static boolean
checkIfSameHeight
(Image first, Image second) static boolean
checkIfSameSize
(Image first, Image second) Checks if two images have the same width and the same heightstatic boolean
checkIfSameWidth
(Image first, Image second) static ImageIcon
static Image
static ImageIcon
createColorSquare
(Color color, int width, int height) static BufferedImage
crop
(BufferedImage src, Rectangle rect) static Image
cropSquircle
(Image original, int fac, int radius, int width, int height, ImageObserver observer) Crops the input image in a squircle shapestatic BufferedImage
darken
(BufferedImage image) static BufferedImage
static ImageIcon
static ImageIcon
static BufferedImage
emptyImageWithSize
(int size, int y, Color color) static BufferedImage
eraseExceptRect
(Image image, int x, int y, int w, int h) static BufferedImage
static ImageIcon
static ImageIcon
static BufferedImage
generateCuboidImage
(Image texture, int x, int y, int z, int xOff, int yOff, int zOff) static BufferedImage
generateCuboidImage
(Image top, Image front, Image side, int x, int y, int z, int xOff, int yOff, int zOff) Generates a cuboid image given the textures, the dimensions, and the offsets on the axes.static float[]
generateGaussianKernel
(int radius) Generates a gaussian kernel compatible with java.awt.image.Kernel objects.static Image
generateShadow
(int radius, int shadowRadius, int shadowExtension, int width, int height) Generates a shadow that fits squircle cropped images.static Image
generateSquircle
(Color color, int fac, int radius, int width, int height, ImageObserver observer) Generates a smooth squircle shapestatic Color
getAverageColor
(BufferedImage image) static float
getAverageLuminance
(BufferedImage image) static BufferedImage
maskTransparency
(BufferedImage base, BufferedImage mask) static BufferedImage
mergeTwoImages
(Image first, Image second, int width, int height, int xFirst, int yFirst, int xSecond, int ySecond) Merges two images to make a single imagestatic BufferedImage
noiseHSV
(BufferedImage image, float hfactor, float sfactor, float vfactor, long seed) static Image
randomTile
(BufferedImage tile, Random random) static Image
static Image
static Image
static Image
static BufferedImage
resizeAndCrop
(Image image, int size) static BufferedImage
static ImageIcon
static BufferedImage
toBufferedImage
(Image img) Converts a given Image into a BufferedImagestatic BufferedImage
-
Constructor Details
-
ImageUtils
public ImageUtils()
-
-
Method Details
-
drawOver
-
drawOver
-
createColorSquare
-
colorize
-
changeSaturation
-
resize
-
resizeAA
-
resize
-
resizeAA
-
resizeAndCrop
-
emptyImageWithSize
-
eraseRect
-
eraseExceptRect
-
maskTransparency
-
toBufferedImage
Converts a given Image into a BufferedImage- Parameters:
img
- The Image to be converted- Returns:
- The converted BufferedImage
-
translate
-
rotate
-
rotate
-
crop
-
cover
-
darken
-
brighten
-
deepCopy
-
noiseHSV
public static BufferedImage noiseHSV(BufferedImage image, float hfactor, float sfactor, float vfactor, long seed) -
fit
-
fit
-
autoCropTile
-
randomTile
-
generateCuboidImage
public static BufferedImage generateCuboidImage(Image texture, int x, int y, int z, int xOff, int yOff, int zOff) -
generateCuboidImage
public static BufferedImage generateCuboidImage(Image top, Image front, Image side, int x, int y, int z, int xOff, int yOff, int zOff) Generates a cuboid image given the textures, the dimensions, and the offsets on the axes.- Parameters:
top
-The top face texture
front
-The front face texture
side
-The side (right) face texture
x
-The length of the cuboid (width of the side face)
y
-The height of the cuboid
z
-The width of the cuboid (width of the front face)
xOff
-The horizontal offset of the cuboid, towards the front face
yOff
-The vertical offset of the cuboid, towards the top face
zOff
-The horizontal of the cuboid, towards the side face
- Returns:
Returns generated image.
-
getAverageColor
-
getAverageLuminance
-
mergeTwoImages
public static BufferedImage mergeTwoImages(Image first, Image second, int width, int height, int xFirst, int yFirst, int xSecond, int ySecond) Merges two images to make a single image- Parameters:
first
-The first image to draw on the new image
second
-The second image to draw on the new image
width
-The width of the final image
height
-The height of the final image
xFirst
-The x position of the first image on the final image
yFirst
-The y position of the first image on the final image
xSecond
-The x position of the second image on the final image
ySecond
-The y position of the second image on the final image
- Returns:
Returns the generated image.
-
checkIfSameWidth
-
checkIfSameHeight
-
checkIfSameSize
Checks if two images have the same width and the same height- Parameters:
first
-The first image
second
-The second image
- Returns:
Returns true if the provided images have the same width and the same height
-
generateSquircle
public static Image generateSquircle(Color color, int fac, int radius, int width, int height, ImageObserver observer) Generates a smooth squircle shape- Parameters:
color
-Color of the generated smooth squircle
fac
-Upscale factor (generates a bigger image before downscaling to get better visual results)
radius
-The squircle corner radius
width
-Squircle width
height
-Squircle height
observer
-Observer used when drawing the image (can be the current swing component)
- Returns:
The generated image
-
cropSquircle
public static Image cropSquircle(Image original, int fac, int radius, int width, int height, ImageObserver observer) Crops the input image in a squircle shape- Parameters:
original
-The original image
fac
-Upscale factor (upscales the image before cropping to produce smooth edges after downscaling to the desired size)
radius
-The squircle corner radius
width
-Squircle width
height
-Squircle height
observer
-Observer used when drawing the image (can be the current swing component)
- Returns:
The cropped image
-
generateShadow
public static Image generateShadow(int radius, int shadowRadius, int shadowExtension, int width, int height) Generates a shadow that fits squircle cropped images.- Parameters:
radius
-The squircle corner radius
shadowRadius
-Width of the blur shadow
shadowExtension
-The squircle extension
width
-Squircle width
height
-Squircle height
- Returns:
Returns the generated shadow.
-
generateGaussianKernel
public static float[] generateGaussianKernel(int radius) Generates a gaussian kernel compatible with java.awt.image.Kernel objects.- Parameters:
radius
-The gaussian kernel radius
- Returns:
The generated kernel
-