com.b3dgs.lionengine.utility
Class Images

java.lang.Object
  extended by com.b3dgs.lionengine.utility.Images

public final class Images
extends java.lang.Object

Set of static functions related to image manipulation.


Method Summary
static java.awt.image.BufferedImage applyFilter(java.awt.image.BufferedImage buffImage, Filter filter)
          Apply a filter to the input buffered image.
static java.awt.image.BufferedImage applyMask(java.awt.Image img, java.awt.Color keyColor)
          Apply color mask to image.
static java.awt.image.BufferedImage createBufferedImage(int width, int height, int transparency)
          Create a compatible buffered image.
static java.awt.image.VolatileImage createVolatileImage(int width, int height, int transparency)
          Create a compatible volatile image.
static int filterRGB(int rgb, int fr, int fg, int fb)
          Apply a filter rgb.
static java.awt.image.BufferedImage flipHorizontal(java.awt.image.BufferedImage src)
          Apply an horizontal flip to the input image.
static java.awt.image.BufferedImage flipVertical(java.awt.image.BufferedImage src)
          Apply a vertical flip to the input image.
static java.awt.image.BufferedImage getBufferedImage(java.lang.String filename, boolean alpha)
          Get a buffered image from an image file.
static java.awt.image.BufferedImage getRasterBuffer(java.awt.image.BufferedImage buf, int fr, int fg, int fb, int er, int eg, int eb, int refSize)
           
static int getRasterColor(int i, int[] data, int max)
          Get raster color.
static java.awt.image.VolatileImage getVolatileImage(java.awt.image.BufferedImage bufImage)
          Get a volatile image from a buffered image.
static java.awt.image.VolatileImage getVolatileImage(java.lang.String filename, int transparency)
          Get a volatile image from an image file.
static int[][] loadRaster(java.lang.String file)
          Load a raster data from a file.
static void optimizeGraphics(java.awt.Graphics2D g)
          Optimize graphic to performance mode.
static void optimizeGraphicsQuality(java.awt.Graphics2D g)
          Enable all graphics improvment.
static void optimizeGraphicsSpeed(java.awt.Graphics2D g)
          Disable all graphics improvment.
static java.awt.image.BufferedImage[] referenceSplit(java.awt.image.BufferedImage image, int row, int col)
          Split an image into a reference of sub image (data shared).
static java.awt.image.BufferedImage resize(java.awt.image.BufferedImage src, int w, int h)
          Resize input buffered image.
static java.awt.image.BufferedImage rotate(java.awt.image.BufferedImage src, int angle)
          Rotate input buffered image.
static void saveImage(java.awt.image.BufferedImage image, java.lang.String imagefile)
          Save an image into a file.
static java.awt.image.BufferedImage[] splitImage(java.awt.image.BufferedImage image, int row, int col)
          Split an image into an array of sub image (data not shared).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

createBufferedImage

public static java.awt.image.BufferedImage createBufferedImage(int width,
                                                               int height,
                                                               int transparency)
Create a compatible buffered image.

Parameters:
width - image width.
height - image height.
transparency - transparency value.
Returns:
buffered image reference.
See Also:
Transparency

createVolatileImage

public static java.awt.image.VolatileImage createVolatileImage(int width,
                                                               int height,
                                                               int transparency)
Create a compatible volatile image.

Parameters:
width - image width.
height - image height.
transparency - transparency value.
Returns:
volatile image reference.
See Also:
Transparency

getBufferedImage

public static java.awt.image.BufferedImage getBufferedImage(java.lang.String filename,
                                                            boolean alpha)
Get a buffered image from an image file.

Parameters:
filename - image filename.
alpha - true to enable alpha.
Returns:
created buffered image from file.

getVolatileImage

public static java.awt.image.VolatileImage getVolatileImage(java.lang.String filename,
                                                            int transparency)
Get a volatile image from an image file.

Parameters:
filename - image filename.
transparency - transparency.
Returns:
created volatile image from file.
See Also:
Transparency

getVolatileImage

public static java.awt.image.VolatileImage getVolatileImage(java.awt.image.BufferedImage bufImage)
Get a volatile image from a buffered image.

Parameters:
bufImage - input buffered image.
Returns:
converted buffered image to volatile image.

applyMask

public static java.awt.image.BufferedImage applyMask(java.awt.Image img,
                                                     java.awt.Color keyColor)
Apply color mask to image.

Parameters:
img - image reference.
keyColor - color mask.
Returns:
masked buffered image.

referenceSplit

public static java.awt.image.BufferedImage[] referenceSplit(java.awt.image.BufferedImage image,
                                                            int row,
                                                            int col)
Split an image into a reference of sub image (data shared).

Parameters:
image - image to split.
row - number of horizontal divisions.
col - number of vertical divisions.
Returns:
splited references.

splitImage

public static java.awt.image.BufferedImage[] splitImage(java.awt.image.BufferedImage image,
                                                        int row,
                                                        int col)
Split an image into an array of sub image (data not shared).

Parameters:
image - image to split.
row - number of horizontal divisions.
col - number of vertical divisions.
Returns:
splited images.

rotate

public static java.awt.image.BufferedImage rotate(java.awt.image.BufferedImage src,
                                                  int angle)
Rotate input buffered image.

Parameters:
src - input buffered image.
angle - angle to apply in degree (0-359)
Returns:
new buffered image with angle applyed.

resize

public static java.awt.image.BufferedImage resize(java.awt.image.BufferedImage src,
                                                  int w,
                                                  int h)
Resize input buffered image.

Parameters:
src - input buffered image.
w - new width.
h - new height.
Returns:
new buffered image with new size.

flipHorizontal

public static java.awt.image.BufferedImage flipHorizontal(java.awt.image.BufferedImage src)
Apply an horizontal flip to the input image.

Parameters:
src - input buffered image.
Returns:
flipped buffered image as a new instance.

flipVertical

public static java.awt.image.BufferedImage flipVertical(java.awt.image.BufferedImage src)
Apply a vertical flip to the input image.

Parameters:
src - input buffered image.
Returns:
flipped buffered image as a new instance.

applyFilter

public static java.awt.image.BufferedImage applyFilter(java.awt.image.BufferedImage buffImage,
                                                       Filter filter)
Apply a filter to the input buffered image.

Parameters:
buffImage - input image.
filter - filter to use.
Returns:
filtered image as a new instance.

saveImage

public static void saveImage(java.awt.image.BufferedImage image,
                             java.lang.String imagefile)
Save an image into a file.

Parameters:
image - image to save.
imagefile - image filename.

loadRaster

public static int[][] loadRaster(java.lang.String file)
Load a raster data from a file.

Parameters:
file - raster file.
Returns:
raster data.

filterRGB

public static int filterRGB(int rgb,
                            int fr,
                            int fg,
                            int fb)
Apply a filter rgb.

Parameters:
rgb - original rgb.
fr - red filter.
fg - green filter.
fb - blue filter.
Returns:
filtered rgb.

getRasterColor

public static int getRasterColor(int i,
                                 int[] data,
                                 int max)
Get raster color.

Parameters:
i - color offset.
data - raster data.
max - max offset.
Returns:
rastered color.

getRasterBuffer

public static java.awt.image.BufferedImage getRasterBuffer(java.awt.image.BufferedImage buf,
                                                           int fr,
                                                           int fg,
                                                           int fb,
                                                           int er,
                                                           int eg,
                                                           int eb,
                                                           int refSize)

optimizeGraphicsQuality

public static void optimizeGraphicsQuality(java.awt.Graphics2D g)
Enable all graphics improvment. May decrease overall performances.

Parameters:
g - graphic context.

optimizeGraphicsSpeed

public static void optimizeGraphicsSpeed(java.awt.Graphics2D g)
Disable all graphics improvment. May increase overall performances.

Parameters:
g - graphic context.

optimizeGraphics

public static void optimizeGraphics(java.awt.Graphics2D g)
Optimize graphic to performance mode.

Parameters:
g - graphic context.