|
GTGE API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.golden.gamedev.util.ImageUtil
public class ImageUtil
Utility class for creating, loading, and manipulating image.
| Field Summary | |
|---|---|
static GraphicsConfiguration |
CONFIG
|
| Method Summary | |
|---|---|
static BufferedImage |
applyMask(Image img,
Color keyColor)
Applying mask into image by specified masking color. |
static BufferedImage |
createImage(int width,
int height)
Creates blank image with specified width, height, without transparency (opaque). |
static BufferedImage |
createImage(int width,
int height,
int transparency)
Creates blank image with specified width, height, and transparency. |
static BufferedImage |
flip(BufferedImage src)
Flips an image. |
static BufferedImage |
fromByteArray(byte[] imagebytes)
Constructs image from byte array. |
static BufferedImage |
getImage(URL url)
Loads an image from URL without transparency (completely opaque). |
static BufferedImage |
getImage(URL url,
Color keyColor)
Loads an image from URL with specified masking color. |
static BufferedImage |
getImage(URL url,
int transparency)
Loads an image from URL and specified transparency. |
static BufferedImage[] |
getImages(URL url,
int col,
int row)
Loads and splits image from URL, without transparency. |
static BufferedImage[] |
getImages(URL url,
int col,
int row,
Color keyColor)
Loads and splits image from URL with specified masking color. |
static BufferedImage[] |
getImages(URL url,
int col,
int row,
int transparency)
Loads and splits image from URL and transparency. |
static BufferedImage |
resize(BufferedImage src,
int w,
int h)
Resizes an image into specified size. |
static BufferedImage |
rotate(BufferedImage src,
int angle)
Rotates an image by specified angle (clockwise). |
static void |
saveImage(BufferedImage image,
File imagefile)
Saves image into specified file. |
static BufferedImage[] |
splitImages(BufferedImage image,
int col,
int row)
Splits a single image into an array of images. |
static byte[] |
toByteArray(BufferedImage image,
String extension)
Saves image into byte array. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final GraphicsConfiguration CONFIG
| Method Detail |
|---|
public static BufferedImage getImage(URL url,
int transparency)
url - image urltransparency - image transparency
Transparency.OPAQUE,
Transparency.BITMASK,
Transparency.TRANSLUCENTpublic static BufferedImage getImage(URL url)
url - image url
public static BufferedImage getImage(URL url,
Color keyColor)
url - image urlkeyColor - masking color
public static BufferedImage[] getImages(URL url,
int col,
int row,
int transparency)
url - image urlcol - columnrow - rowtransparency - image transparency
Transparency.OPAQUE,
Transparency.BITMASK,
Transparency.TRANSLUCENT
public static BufferedImage[] getImages(URL url,
int col,
int row)
url - image urlcol - columnrow - row
public static BufferedImage[] getImages(URL url,
int col,
int row,
Color keyColor)
url - image urlcol - columnrow - rowkeyColor - masking color
public static BufferedImage createImage(int width,
int height,
int transparency)
width - image widthheight - image heighttransparency - image transparency
Transparency.OPAQUE,
Transparency.BITMASK,
Transparency.TRANSLUCENT
public static BufferedImage createImage(int width,
int height)
width - image widthheight - image height
public static BufferedImage applyMask(Image img,
Color keyColor)
Color in the image that match with specified masking color will be converted to transparent.
img - the source imagekeyColor - masking color
public static BufferedImage[] splitImages(BufferedImage image,
int col,
int row)
image - the source imagecol - image columnrow - image row
public static BufferedImage rotate(BufferedImage src,
int angle)
For example:
BufferedImage image;
// rotate the image by 90 degree clockwise
BufferedImage rotated = ImageUtil.rotate(image, 90);
src - the source imageangle - angle rotation
public static BufferedImage resize(BufferedImage src,
int w,
int h)
For example:
BufferedImage image;
// resize the image to 200x300 size
BufferedImage resized = ImageUtil.resize(image, 200, 300);
// double the size of the image
BufferedImage doubleResize = ImageUtil.resize(image,
image.getWidth()*2,
image.getHeight()*2);
src - the source imagew - width of the resized imageh - height of the resized image
public static BufferedImage flip(BufferedImage src)
src - the source image
public static void saveImage(BufferedImage image,
File imagefile)
image - image to be savedimagefile - file where the image will be saved
public static byte[] toByteArray(BufferedImage image,
String extension)
image - image to be savedextension - the image extension (png)
fromByteArray(byte[])public static BufferedImage fromByteArray(byte[] imagebytes)
imagebytes - image in byte array
toByteArray(BufferedImage, String)
|
GTGE API | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||