Class ImageUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic BufferedImageautoCropTile(BufferedImage tile) static BufferedImagebrighten(BufferedImage image) static ImageIconchangeSaturation(ImageIcon icon, float modifier) static booleancheckIfSameHeight(Image first, Image second) static booleancheckIfSameSize(Image first, Image second) Checks if two images have the same width and the same heightstatic booleancheckIfSameWidth(Image first, Image second) static ImageIconstatic Imagestatic ImageIconcreateColorSquare(Color color, int width, int height) static BufferedImagecrop(BufferedImage src, Rectangle rect) static ImagecropSquircle(Image original, int fac, int radius, int width, int height, ImageObserver observer) Crops the input image in a squircle shapestatic BufferedImagedarken(BufferedImage image) static BufferedImagestatic ImageIconstatic ImageIconstatic BufferedImageemptyImageWithSize(int size, int y, Color color) static BufferedImageeraseExceptRect(Image image, int x, int y, int w, int h) static BufferedImagestatic ImageIconstatic ImageIconstatic BufferedImagegenerateCuboidImage(Image texture, int x, int y, int z, int xOff, int yOff, int zOff) static BufferedImagegenerateCuboidImage(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 ImagegenerateShadow(int radius, int shadowRadius, int shadowExtension, int width, int height) Generates a shadow that fits squircle cropped images.static ImagegenerateSquircle(Color color, int fac, int radius, int width, int height, ImageObserver observer) Generates a smooth squircle shapestatic ColorgetAverageColor(BufferedImage image) static floatgetAverageLuminance(BufferedImage image) static BufferedImagemaskTransparency(BufferedImage base, BufferedImage mask) static BufferedImagemergeTwoImages(Image first, Image second, int width, int height, int xFirst, int yFirst, int xSecond, int ySecond) Merges two images to make a single imagestatic BufferedImagenoiseHSV(BufferedImage image, float hfactor, float sfactor, float vfactor, long seed) static ImagerandomTile(BufferedImage tile, Random random) static Imagestatic Imagestatic Imagestatic Imagestatic BufferedImageresizeAndCrop(Image image, int size) static BufferedImagestatic ImageIconstatic BufferedImagetoBufferedImage(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
-