Package org.carrot2.util
Class BufferedImageUtils
java.lang.Object
org.carrot2.util.BufferedImageUtils
Various utility methods for working with
BufferedImage
s.-
Method Summary
Modifier and TypeMethodDescriptionstatic int
countDistinctColors
(BufferedImage image) Returns the number of distinct colors (excluding transparency) in theimage
.static void
drawImage
(BufferedImage image, BufferedImage canvas, int x, int y) Drawsimage
on thecanvas
placing the top left corner ofimage
atx
/y
offset from the top left corner ofcanvas
.static int[]
getDistinctColors
(BufferedImage image) Returns theimage
's distinct colors in an RGB format, discarding transparency information.static int[]
getDistinctColors
(BufferedImage image, int padding) Returns theimage
's distinct colors in an RGB format, discarding transparency information.static int[][]
getRgb
(BufferedImage image) Returns a two dimensional array of theimage
's RGB values, including transparency.static boolean
Returnstrue
if the provided image has partially transparent areas (alpha channel).static boolean
hasTransparency
(BufferedImage image) Returnstrue
if the provided image has any kind of transparent areas.static BufferedImage
matte
(BufferedImage source, Color matteColor) Performs matting of thesource
image usingmatteColor
.
-
Method Details
-
hasPartialTransparency
Returnstrue
if the provided image has partially transparent areas (alpha channel).- Parameters:
image
- the image- Returns:
- true, if successful
-
hasTransparency
Returnstrue
if the provided image has any kind of transparent areas.- Parameters:
image
- the image- Returns:
- true, if successful
-
countDistinctColors
Returns the number of distinct colors (excluding transparency) in theimage
.- Parameters:
image
- the image- Returns:
- the int
-
getDistinctColors
Returns theimage
's distinct colors in an RGB format, discarding transparency information.- Parameters:
image
- the image- Returns:
- the distinct colors
-
getDistinctColors
Returns theimage
's distinct colors in an RGB format, discarding transparency information. Addspadding
empty slots at the beginning of the returned array.- Parameters:
image
- the imagepadding
- the padding- Returns:
- the distinct colors
-
getRgb
Returns a two dimensional array of theimage
's RGB values, including transparency.- Parameters:
image
- the image- Returns:
- the rgb
-
matte
Performs matting of thesource
image usingmatteColor
. Matting is rendering partial transparencies using solid color as if the original image was put on top of a bitmap filled withmatteColor
.- Parameters:
source
- the sourcematteColor
- the matte color- Returns:
- the buffered image
-
drawImage
Drawsimage
on thecanvas
placing the top left corner ofimage
atx
/y
offset from the top left corner ofcanvas
.- Parameters:
image
- the imagecanvas
- the canvasx
- the xy
- the y
-