public class ImageUtils extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ImageUtils.ImageType
Image type
|
Modifier and Type | Field and Description |
---|---|
static Color |
TRANSPARENT |
Constructor and Description |
---|
ImageUtils() |
Modifier and Type | Method and Description |
---|---|
static BufferedImage |
addBorder(BufferedImage source,
int borderSizePixels,
Color borderColor)
Creates a new image that adds a border of the given thickness and color to the image (so the image size grows)
|
static BufferedImage |
createCircle(int iconHeight,
Color fillColor)
Creates an image of a filled circle of the given color, the rest is transparent
|
static BufferedImage |
createImageFromShape(Shape s)
Creates an image from the given shape
|
static BufferedImage |
imageToBufferedImage(Image image)
Converts an
Image to a BufferedImage . |
static BufferedImage |
readImageFromFile(File file)
Reads an image from a file.
|
static BufferedImage |
readImageFromURL(URL url)
Reads an image from an URL.
|
static BufferedImage |
resize(BufferedImage image,
int width,
int height)
Resizes an image.
|
static BufferedImage |
takeSnapshot(JComponent component)
Takes an snapshot of the current state of a component.
|
static BufferedImage |
trim(BufferedImage img)
Removes the white borders of a
BufferedImage . |
static void |
writeImageToFile(File file,
BufferedImage bufferedImage,
ImageUtils.ImageType imageType)
Writes an image to a file.
|
public static Color TRANSPARENT
public static BufferedImage addBorder(BufferedImage source, int borderSizePixels, Color borderColor)
source
- the source imageborderSizePixels
- the thickness in pixelsborderColor
- the border colorpublic static BufferedImage createCircle(int iconHeight, Color fillColor)
iconHeight
- the height and width of the created image, and the diameter of the circlefillColor
- the color to fill the circlepublic static BufferedImage createImageFromShape(Shape s)
s
- the shapepublic static BufferedImage imageToBufferedImage(Image image)
Image
to a BufferedImage
.image
- Image
BufferedImage
public static BufferedImage readImageFromFile(File file)
file
- FileBufferedImage
public static BufferedImage readImageFromURL(URL url)
url
- URLBufferedImage
public static BufferedImage resize(BufferedImage image, int width, int height)
image
- Source image to scalewidth
- Desired widthheight
- Desired heightpublic static BufferedImage takeSnapshot(JComponent component)
component
- Source componentBufferedImage
public static BufferedImage trim(BufferedImage img)
BufferedImage
.img
- Input imagepublic static void writeImageToFile(File file, BufferedImage bufferedImage, ImageUtils.ImageType imageType)
file
- Output filebufferedImage
- Image to saveimageType
- Image type (bmp, jpg, png)Copyright © 2018. All rights reserved.