public class ImageUtil extends java.lang.Object
Constructor and Description |
---|
ImageUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
applyColorFilter(java.awt.Image image,
java.awt.Color color,
float alpha)
Apply simple color filter with specified alpha factor to the image
|
static java.awt.image.BufferedImage |
convert(java.awt.Image in,
java.awt.image.BufferedImage out)
Convert an image to a BufferedImage.
|
static java.awt.image.BufferedImage |
convertImage(java.awt.Image in,
java.awt.image.BufferedImage out)
Deprecated.
Use
convert(Image, BufferedImage) instead. |
static java.awt.image.BufferedImage |
createIndexedImage(int w,
int h,
java.awt.image.IndexColorModel cm,
byte[] data)
Create a 8 bits indexed buffered image from specified
IndexColorModel and byte array data. |
static void |
drawText(java.awt.Image image,
java.lang.String text,
float x,
float y,
int size,
java.awt.Color color)
Draw text in the specified image with specified parameters.
|
static void |
drawTextTopRight(java.awt.Image image,
java.lang.String text,
int size,
boolean bold,
java.awt.Color color)
Draw text at top right in the specified image with specified parameters.
|
static java.awt.Image |
getColorImageFromAlphaImage(java.awt.Image alphaImage,
java.awt.Color color)
Return an image which contains specified color depending original alpha intensity image
|
static java.awt.image.BufferedImage |
getCopy(java.awt.Image in)
Create a copy of the input image.
|
static java.lang.String |
getImageTypeString(int type) |
static java.util.List<java.awt.Rectangle> |
getTileList(int sizeX,
int sizeY,
int tileW,
int tileH)
Get the list of tiles to fill the given XY plan size.
|
static java.util.List<java.awt.Rectangle> |
getTileList(java.awt.Rectangle region,
int tileW,
int tileH)
Get the list of tiles to cover the given XY region.
|
static java.lang.String |
getTransparencyString(int transparency) |
static boolean |
isGray(java.awt.image.BufferedImage image)
Returns
true if the specified image is a grayscale image whatever is the image
type (GRAY, RGB, ARGB...) |
static java.awt.image.BufferedImage |
load(java.io.File file)
Load an image from specified file
|
static java.awt.image.BufferedImage |
load(java.io.File file,
boolean displayError)
Load an image from specified file
|
static java.awt.image.BufferedImage |
load(java.io.InputStream input)
Load an image from specified InputStream
|
static java.awt.image.BufferedImage |
load(java.io.InputStream input,
boolean displayError)
Load an image from specified InputStream
|
static java.awt.image.BufferedImage |
load(java.lang.String path)
Load an image from specified path
|
static java.awt.image.BufferedImage |
load(java.lang.String path,
boolean displayError)
Load an image from specified path
|
static java.awt.image.BufferedImage |
load(java.net.URL url)
Load an image from specified url
|
static java.awt.image.BufferedImage |
load(java.net.URL url,
boolean displayError)
Load an image from specified url
|
static java.awt.Image |
loadAsync(java.lang.String path)
Asynchronously load an image from specified path.
|
static java.awt.Image |
loadAsync(java.net.URL url)
Asynchronously load an image from specified url.
|
static java.awt.image.BufferedImage |
loadImage(java.io.File file)
Deprecated.
Use
load(File) instead |
static java.awt.image.BufferedImage |
loadImage(java.io.File file,
boolean displayError)
Deprecated.
Use
load(File, boolean) instead |
static java.awt.image.BufferedImage |
loadImage(java.io.InputStream input)
Deprecated.
Use
load(InputStream) instead |
static java.awt.image.BufferedImage |
loadImage(java.io.InputStream input,
boolean displayError)
Deprecated.
Use
load(InputStream, boolean) instead |
static java.awt.image.BufferedImage |
loadImage(java.lang.String path)
Deprecated.
Use
load(String) instead |
static java.awt.image.BufferedImage |
loadImage(java.lang.String path,
boolean displayError)
Deprecated.
Use
load(String, boolean) instead |
static java.awt.Image |
loadImage(java.net.URL url)
Deprecated.
Use
load(URL) instead |
static java.awt.image.BufferedImage |
loadImage(java.net.URL url,
boolean displayError)
Deprecated.
Use
load(URL, boolean) instead |
static java.awt.Image |
paintColorImageFromAlphaImage(java.awt.Image alphaImage,
java.awt.Image out,
java.awt.Color color)
Paint the specified color in 'out' image depending original alpha intensity from 'alphaImage'
|
static boolean |
sameSize(java.awt.image.BufferedImage im1,
java.awt.image.BufferedImage im2)
Return true if image has the same size
|
static boolean |
save(java.awt.image.RenderedImage image,
java.lang.String format,
java.io.File file)
Save an image to specified file in specified format
|
static boolean |
save(java.awt.image.RenderedImage image,
java.lang.String format,
java.lang.String path)
Save an image to specified path in specified format
|
static boolean |
saveImage(java.awt.image.RenderedImage image,
java.lang.String format,
java.io.File file)
Deprecated.
Use
save(RenderedImage, String, File) instead |
static boolean |
saveImage(java.awt.image.RenderedImage image,
java.lang.String format,
java.lang.String path)
Deprecated.
Use
save(RenderedImage, String, String) instead |
static java.awt.image.BufferedImage |
scale(java.awt.Image image,
int width,
int height)
Scale an image with specified size.
|
static java.awt.image.BufferedImage |
scaleImage(java.awt.Image image,
int width,
int height)
Deprecated.
Use
scale(Image, int, int) instead. |
static java.awt.image.BufferedImage |
scaleImageQuality(java.awt.Image image,
int width,
int height)
Deprecated.
Use
scaleQuality(Image, int, int) instead. |
static java.awt.image.BufferedImage |
scaleQuality(java.awt.Image image,
int width,
int height)
Scale an image with specified size (try to keep best quality).
|
static java.awt.image.BufferedImage |
toARGBImage(java.awt.Image image)
Convert an image to ARGB image (
BufferedImage.TYPE_INT_ARGB ). |
static java.awt.image.BufferedImage |
toBufferedImage(java.awt.Image image)
Return a ARGB BufferedImage from the given Image object.
|
static java.awt.image.BufferedImage |
toGray(java.awt.Image image)
Convert an image to grey image (
BufferedImage.TYPE_BYTE_GRAY ). |
static java.awt.image.BufferedImage |
toGrayImage(java.awt.Image image)
Deprecated.
Use
toGray(Image) instead. |
static java.awt.image.RenderedImage |
toRenderedImage(java.awt.Image image)
Return a RenderedImage from the given Image object.
|
static java.awt.image.BufferedImage |
toRGBImage(java.awt.Image image)
Convert an image to RGB image (
BufferedImage.TYPE_INT_RGB ). |
static void |
waitImageReady(java.awt.Image image)
Wait for dimension information of specified image being loaded.
|
public ImageUtil()
public static java.lang.String getImageTypeString(int type)
public static java.lang.String getTransparencyString(int transparency)
public static void waitImageReady(java.awt.Image image)
image
- image we are waiting informations for.public static java.awt.image.BufferedImage createIndexedImage(int w, int h, java.awt.image.IndexColorModel cm, byte[] data)
IndexColorModel
public static java.awt.image.BufferedImage load(java.lang.String path, boolean displayError)
public static java.awt.image.BufferedImage load(java.lang.String path)
public static java.awt.image.BufferedImage load(java.net.URL url, boolean displayError)
public static java.awt.Image loadAsync(java.net.URL url)
waitImageReady(Image)
to know if width and height propertypublic static java.awt.Image loadAsync(java.lang.String path)
waitImageReady(Image)
to know if width and height propertypublic static java.awt.image.BufferedImage load(java.net.URL url)
public static java.awt.image.BufferedImage load(java.io.File file, boolean displayError)
public static java.awt.image.BufferedImage load(java.io.File file)
public static java.awt.image.BufferedImage load(java.io.InputStream input, boolean displayError)
public static java.awt.image.BufferedImage load(java.io.InputStream input)
@Deprecated public static java.awt.image.BufferedImage loadImage(java.lang.String path, boolean displayError)
load(String, boolean)
instead@Deprecated public static java.awt.image.BufferedImage loadImage(java.lang.String path)
load(String)
instead@Deprecated public static java.awt.image.BufferedImage loadImage(java.net.URL url, boolean displayError)
load(URL, boolean)
instead@Deprecated public static java.awt.Image loadImage(java.net.URL url)
load(URL)
instead@Deprecated public static java.awt.image.BufferedImage loadImage(java.io.File file, boolean displayError)
load(File, boolean)
instead@Deprecated public static java.awt.image.BufferedImage loadImage(java.io.File file)
load(File)
instead@Deprecated public static java.awt.image.BufferedImage loadImage(java.io.InputStream input, boolean displayError)
load(InputStream, boolean)
instead@Deprecated public static java.awt.image.BufferedImage loadImage(java.io.InputStream input)
load(InputStream)
insteadpublic static boolean save(java.awt.image.RenderedImage image, java.lang.String format, java.lang.String path)
public static boolean save(java.awt.image.RenderedImage image, java.lang.String format, java.io.File file)
@Deprecated public static boolean saveImage(java.awt.image.RenderedImage image, java.lang.String format, java.lang.String path)
save(RenderedImage, String, String)
instead@Deprecated public static boolean saveImage(java.awt.image.RenderedImage image, java.lang.String format, java.io.File file)
save(RenderedImage, String, File)
insteadpublic static java.awt.image.RenderedImage toRenderedImage(java.awt.Image image)
public static java.awt.image.BufferedImage toBufferedImage(java.awt.Image image)
public static java.awt.image.BufferedImage scale(java.awt.Image image, int width, int height)
public static java.awt.image.BufferedImage scaleQuality(java.awt.Image image, int width, int height)
public static java.awt.image.BufferedImage convert(java.awt.Image in, java.awt.image.BufferedImage out)
out is null, by default a BufferedImage.TYPE_INT_ARGB
is created.
public static boolean isGray(java.awt.image.BufferedImage image)
true
if the specified image is a grayscale image whatever is the image
type (GRAY, RGB, ARGB...)public static java.awt.image.BufferedImage toGray(java.awt.Image image)
BufferedImage.TYPE_BYTE_GRAY
).public static java.awt.image.BufferedImage toRGBImage(java.awt.Image image)
BufferedImage.TYPE_INT_RGB
).public static java.awt.image.BufferedImage toARGBImage(java.awt.Image image)
BufferedImage.TYPE_INT_ARGB
).@Deprecated public static java.awt.image.BufferedImage scaleImage(java.awt.Image image, int width, int height)
scale(Image, int, int)
instead.@Deprecated public static java.awt.image.BufferedImage scaleImageQuality(java.awt.Image image, int width, int height)
scaleQuality(Image, int, int)
instead.@Deprecated public static java.awt.image.BufferedImage convertImage(java.awt.Image in, java.awt.image.BufferedImage out)
convert(Image, BufferedImage)
instead.@Deprecated public static java.awt.image.BufferedImage toGrayImage(java.awt.Image image)
toGray(Image)
instead.public static java.awt.image.BufferedImage getCopy(java.awt.Image in)
BufferedImage.TYPE_INT_ARGB
type image.public static boolean sameSize(java.awt.image.BufferedImage im1, java.awt.image.BufferedImage im2)
public static java.util.List<java.awt.Rectangle> getTileList(java.awt.Rectangle region, int tileW, int tileH)
region
- the XY region to covertileW
- tile widthtileH
- tile heightpublic static java.util.List<java.awt.Rectangle> getTileList(int sizeX, int sizeY, int tileW, int tileH)
sizeX
- plan sizeXsizeY
- plan sizeYtileW
- tile widthtileH
- tile heightpublic static void applyColorFilter(java.awt.Image image, java.awt.Color color, float alpha)
public static java.awt.Image getColorImageFromAlphaImage(java.awt.Image alphaImage, java.awt.Color color)
public static java.awt.Image paintColorImageFromAlphaImage(java.awt.Image alphaImage, java.awt.Image out, java.awt.Color color)
public static void drawText(java.awt.Image image, java.lang.String text, float x, float y, int size, java.awt.Color color)
public static void drawTextTopRight(java.awt.Image image, java.lang.String text, int size, boolean bold, java.awt.Color color)