public class ImageUtil extends Object
Modifier and Type | Class and Description |
---|---|
static class |
ImageUtil.ImageProperties
Contains ImageUtil-internal information about an image.
|
Constructor and Description |
---|
ImageUtil() |
Modifier and Type | Method and Description |
---|---|
static BufferedImage |
cloneImage(BufferedImage sourceImage)
Clones the given BufferedImage
|
static int[] |
createSampleBuffer()
Create a 16x16 sample buffer with space for 4 color bands
|
static List<BufferedImage> |
cropToBeSameSize(BufferedImage image1,
BufferedImage image2)
Resize images to be same size.
|
static String |
encodeImageToBase64(BufferedImage image)
Encodes target image to a Base64 string
|
static int[] |
getBlock(ImageUtil.ImageProperties properties,
int x,
int y,
int[] result,
int[] sample)
Returns the 16x16 RGB block starting at (x,y) from the given image
|
static ImageUtil.ImageProperties |
getImageProperties(BufferedImage image)
Extract magical image properties used by the getBlock function.
|
static double |
getLuminance(int rgb)
Get luminance value for the given rgb value.
|
static boolean |
imagesSameSize(BufferedImage image1,
BufferedImage image2)
Check canvas sizes and resize images to same size
|
public static String encodeImageToBase64(BufferedImage image)
image
- BufferedImage to encode to Stringpublic static double getLuminance(int rgb)
rgb
- public static boolean imagesSameSize(BufferedImage image1, BufferedImage image2)
public static List<BufferedImage> cropToBeSameSize(BufferedImage image1, BufferedImage image2)
image1
- an image.image2
- an image.public static final int[] createSampleBuffer()
public static final ImageUtil.ImageProperties getImageProperties(BufferedImage image)
image
- a BufferedImagepublic static final int[] getBlock(ImageUtil.ImageProperties properties, int x, int y, int[] result, int[] sample)
properties
- The properties of the image (image + metadata)x
- The x coordinate of the block (in pixels)y
- The y coordinate of the block (in pixels)result
- A sample buffer (32 bits per pixel) for storing the resulting
block, or null (a new buffer will be created)sample
- A sample buffer for storing intermediate values, or null (a
new buffer will be created). This parameter is provided mainly
for speed (providing it eliminates unnecessary block
allocations).public static BufferedImage cloneImage(BufferedImage sourceImage)
sourceImage
- The image to copyCopyright © 2019. All rights reserved.