public final class ImageUtil
extends java.lang.Object
Constructor and Description |
---|
ImageUtil() |
Modifier and Type | Method and Description |
---|---|
static java.awt.image.BufferedImage |
createImage(java.awt.GraphicsConfiguration gc,
int width,
int height,
int type)
Creates a HiDPI-aware BufferedImage in the graphics config scale.
|
static java.awt.image.BufferedImage |
createImage(java.awt.Graphics g,
double width,
double height,
int type,
PaintUtil.RoundingMode rm) |
static java.awt.image.BufferedImage |
createImage(java.awt.Graphics g,
int width,
int height,
int type)
Creates a HiDPI-aware BufferedImage in the graphics device scale.
|
static java.awt.image.BufferedImage |
createImage(int width,
int height,
int type)
Creates a HiDPI-aware BufferedImage in device scale.
|
static java.awt.Image |
ensureHiDPI(java.awt.Image image,
JBUI.ScaleContext ctx)
Deprecated.
|
static java.awt.Image |
ensureHiDPI(java.awt.Image image,
ScaleContext ctx)
|
static java.awt.Image |
ensureHiDPI(java.awt.Image image,
ScaleContext ctx,
double userWidth,
double userHeight)
|
static java.awt.Image |
filter(java.awt.Image image,
java.awt.image.ImageFilter filter) |
static double |
getImageScale(java.awt.Image image) |
static int |
getRealHeight(java.awt.Image image) |
static int |
getRealWidth(java.awt.Image image) |
static int |
getUserHeight(java.awt.Image image) |
static int |
getUserWidth(java.awt.Image image) |
static java.awt.Image |
scaleImage(java.awt.Image image,
double scale)
Scales the image taking into account its HiDPI awareness.
|
static java.awt.Image |
scaleImage(java.awt.Image image,
int width,
int height)
Scales the image taking into account its HiDPI awareness.
|
static java.awt.image.BufferedImage |
toBufferedImage(java.awt.Image image) |
static java.awt.image.BufferedImage |
toBufferedImage(java.awt.Image image,
boolean inUserSize) |
public static java.awt.image.BufferedImage createImage(int width, int height, int type)
width
- the width in user coordinate spaceheight
- the height in user coordinate spacetype
- the type of the imagejava.lang.IllegalArgumentException
- if width
or height
is not greater than 0public static java.awt.image.BufferedImage createImage(java.awt.GraphicsConfiguration gc, int width, int height, int type)
gc
- the graphics configwidth
- the width in user coordinate spaceheight
- the height in user coordinate spacetype
- the type of the imagejava.lang.IllegalArgumentException
- if width
or height
is not greater than 0public static java.awt.image.BufferedImage createImage(java.awt.Graphics g, int width, int height, int type)
g
- the graphics of the target devicewidth
- the width in user coordinate spaceheight
- the height in user coordinate spacetype
- the type of the imagejava.lang.IllegalArgumentException
- if width
or height
is not greater than 0public static java.awt.image.BufferedImage createImage(java.awt.Graphics g, double width, double height, int type, PaintUtil.RoundingMode rm)
java.lang.IllegalArgumentException
- if width
or height
is not greater than 0#createImage(GraphicsConfiguration, double, double, int, PaintUtil.RoundingMode)
public static java.awt.image.BufferedImage toBufferedImage(java.awt.Image image)
public static java.awt.image.BufferedImage toBufferedImage(java.awt.Image image, boolean inUserSize)
public static double getImageScale(java.awt.Image image)
public static int getRealWidth(java.awt.Image image)
public static int getRealHeight(java.awt.Image image)
public static int getUserWidth(java.awt.Image image)
public static int getUserHeight(java.awt.Image image)
public static java.awt.Image filter(java.awt.Image image, java.awt.image.ImageFilter filter)
public static java.awt.Image scaleImage(java.awt.Image image, double scale)
public static java.awt.Image scaleImage(java.awt.Image image, int width, int height)
width
- target user widthheight
- target user heightpublic static java.awt.Image ensureHiDPI(java.awt.Image image, ScaleContext ctx)
@Deprecated public static java.awt.Image ensureHiDPI(java.awt.Image image, JBUI.ScaleContext ctx)
ensureHiDPI(Image, ScaleContext)
.public static java.awt.Image ensureHiDPI(java.awt.Image image, ScaleContext ctx, double userWidth, double userHeight)
image
with JBHiDPIScaledImage
according to ctx
when applicable.
The real (dev) width/height of the provided image is usually calculated based on the scale context and the
expected user width/height of the target wrapped image. In the ensureHiDPI(Image, ScaleContext)
method version,
the expected user width/height of the wrapped image is reconstructed from the image's real width/height and the scale context.
However, the real with/height may lose precision (as it is integer) and as the result the reconstructed user width/height
may differ from the original values. To avoid the loss this method version accepts the original user width/height.image
- the raw image to wrapctx
- the scale context to matchuserWidth
- the expected user width of the wrapped imageuserHeight
- the expected user height of the wrapped image