Package com.vaadin.testbench.screenshot
Class ImageUtil
- java.lang.Object
-
- com.vaadin.testbench.screenshot.ImageUtil
-
public class ImageUtil extends Object
These image utility functions are for internal use only.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImageUtil.ImagePropertiesContains ImageUtil-internal information about an image.
-
Constructor Summary
Constructors Constructor Description ImageUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static BufferedImagecloneImage(BufferedImage sourceImage)Clones the given BufferedImagestatic int[]createSampleBuffer()Create a 16x16 sample buffer with space for 4 color bandsstatic List<BufferedImage>cropToBeSameSize(BufferedImage image1, BufferedImage image2)Resize images to be same size.static StringencodeImageToBase64(BufferedImage image)Encodes target image to a Base64 stringstatic 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 imagestatic ImageUtil.ImagePropertiesgetImageProperties(BufferedImage image)Extract magical image properties used by the getBlock function.static doublegetLuminance(int rgb)Get luminance value for the given rgb value.static booleanimagesSameSize(BufferedImage image1, BufferedImage image2)Check canvas sizes and resize images to same size
-
-
-
Method Detail
-
encodeImageToBase64
public static String encodeImageToBase64(BufferedImage image)
Encodes target image to a Base64 string- Parameters:
image- BufferedImage to encode to String- Returns:
- Base64 encoded String of image
-
getLuminance
public static double getLuminance(int rgb)
Get luminance value for the given rgb value.- Parameters:
rgb-- Returns:
-
imagesSameSize
public static boolean imagesSameSize(BufferedImage image1, BufferedImage image2)
Check canvas sizes and resize images to same size- Returns:
- true/false
-
cropToBeSameSize
public static List<BufferedImage> cropToBeSameSize(BufferedImage image1, BufferedImage image2)
Resize images to be same size. The size is determined by the minimum height and minimum width of the images.- Parameters:
image1- an image.image2- an image.- Returns:
- a list containing two images with the same dimensions
-
createSampleBuffer
public static final int[] createSampleBuffer()
Create a 16x16 sample buffer with space for 4 color bands- Returns:
-
getImageProperties
public static final ImageUtil.ImageProperties getImageProperties(BufferedImage image)
Extract magical image properties used by the getBlock function.- Parameters:
image- a BufferedImage- Returns:
- an ImageProperties descriptor object
-
getBlock
public static final 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- Parameters:
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).- Returns:
- An array of RGB values for the block
-
cloneImage
public static BufferedImage cloneImage(BufferedImage sourceImage)
Clones the given BufferedImage- Parameters:
sourceImage- The image to copy- Returns:
- A copy of sourceImage
-
-