public final class BitmapImageUtil extends Object
Modifier and Type | Method and Description |
---|---|
static int |
convertToGray(int rgb)
Convert an RGB color value to a grayscale from 0 to 100.
|
static int |
convertToGray(int r,
int g,
int b)
Convert an RGB color value to a grayscale from 0 to 100.
|
static BufferedImage |
convertToGrayscale(RenderedImage img,
Dimension targetDimension)
Converts an image to a grayscale (8 bits) image.
|
static BufferedImage |
convertToMonochrome(RenderedImage img,
Dimension targetDimension)
Converts an image to a monochrome 1-bit image.
|
static RenderedImage |
convertToMonochrome(RenderedImage img,
Dimension targetDimension,
float quality)
Converts an image to a monochrome 1-bit image.
|
static BufferedImage |
convertTosRGB(RenderedImage img,
Dimension targetDimension)
Converts an image to sRGB.
|
static MonochromeBitmapConverter |
createDefaultMonochromeBitmapConverter() |
static int |
getColorIndexSize(RenderedImage img)
Returns the size of the color index if the given image has one.
|
static boolean |
isGrayscaleImage(RenderedImage img)
Indicates whether an image is a grayscale image.
|
static boolean |
isMonochromeImage(RenderedImage img)
Indicates whether an image is a monochrome (1 bit black and white) image.
|
static boolean |
isZeroBlack(RenderedImage img)
Indicates whether a zero bit indicates a black/dark pixel for a monochrome image.
|
static BufferedImage |
toBufferedImage(RenderedImage img)
Returns a BufferedImage based on the given RenderedImage.
|
public static boolean isMonochromeImage(RenderedImage img)
img
- the imagepublic static boolean isZeroBlack(RenderedImage img)
img
- the image (must be 1 bit monochrome)public static int convertToGray(int r, int g, int b)
r
- the red componentg
- the green componentb
- the blue componentpublic static int convertToGray(int rgb)
rgb
- the RGB valuepublic static int getColorIndexSize(RenderedImage img)
img
- the imagepublic static boolean isGrayscaleImage(RenderedImage img)
img
- the imagepublic static BufferedImage convertTosRGB(RenderedImage img, Dimension targetDimension)
img
- the image to be convertedtargetDimension
- the new target dimensions or null if no scaling is necessarypublic static BufferedImage convertToGrayscale(RenderedImage img, Dimension targetDimension)
img
- the image to be convertedtargetDimension
- the new target dimensions or null if no scaling is necessarypublic static BufferedImage convertToMonochrome(RenderedImage img, Dimension targetDimension)
img
- the image to be convertedtargetDimension
- the new target dimensions or null if no scaling is necessarypublic static RenderedImage convertToMonochrome(RenderedImage img, Dimension targetDimension, float quality)
img
- the image to be convertedtargetDimension
- the new target dimensions or null if no scaling is necessaryquality
- Defines the desired quality level for the conversion.
Valid values: a value between 0.0f (fastest) and 1.0f (best)public static BufferedImage toBufferedImage(RenderedImage img)
img
- the original imagepublic static MonochromeBitmapConverter createDefaultMonochromeBitmapConverter()
Copyright © 2025 Apache Software Foundation. All rights reserved.