|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object game.graphics.image.CImageProcessor
public class CImageProcessor
Gathers standard operations on BufferedImages and pixel operations, such as zoom or bluring.
Any affine transformation matrix (zoom, rotation) or convolve operation (gaussian blur, edge detect) can be applied with provided algos and functions.
CAffineTransform
Field Summary | |
---|---|
static int |
A_MASK
|
static int |
A_OFFSET
|
static int |
B_MASK
|
static int |
B_OFFSET
|
static int |
BYTE_MASK
|
static int |
G_MASK
|
static int |
G_OFFSET
|
int |
H
|
protected int[] |
m_aBasePixels
|
private int[] |
m_aProcessedPixels
|
protected java.awt.image.BufferedImage |
m_bufferedImage
|
private int |
m_param
|
private int |
NB_PIXELS
|
static int |
R_MASK
|
static int |
R_OFFSET
|
static int |
RGB_MASK
|
protected int |
SCAN_SIZE
|
int |
W
|
Constructor Summary | |
---|---|
CImageProcessor(CImageProcessor rhs)
Copy a CImageProcessor (image data is copied too) |
|
CImageProcessor(java.awt.Image img)
Builds a CImageProcessor from an Image |
|
CImageProcessor(int w,
int h)
Builds a blank CImageProcessor. |
|
CImageProcessor(int w,
int h,
boolean bCompatible)
|
Method Summary | |
---|---|
void |
affineTransform(CAffineTransform transform)
Applies an affine transformation (such as zoom or rotation) to the whole image. |
void |
affineTransformAA(CAffineTransform transform)
The resulting image is 4x4 anti-aliased. |
void |
colorAdd(java.awt.Color color,
boolean bSavePixels)
adds a color value to each pixel. |
void |
colorFilter(java.awt.Color color,
boolean bSavePixels)
Applies a color filter to the image. |
private int |
colorLerp(int fpX,
int color1,
int color2)
Linear interpolation between two colors. |
void |
convolve(int[][] fpKernel)
Does a convolve operation given a kernel, be it a gaussian blur or edge enhacement. |
static java.awt.image.BufferedImage |
createARGBImage(int w,
int h)
Creates a translucent BufferedImage can be optimally processed as an int[]. |
static java.awt.image.BufferedImage |
createCompatibleImage(int w,
int h)
Creates a translucent BufferedImage that can be optimally blitted to the screen. |
void |
drawImage(java.awt.Graphics g,
int x,
int y)
Draws the image to a Graphics. |
void |
fourCornersGradient(int topLeftColor,
int topRightColor,
int bottomRightColor,
int bottomLeftColor)
Generates a gradient interpolated from four colors (one at each corner) covering the whole image. |
protected int |
getA(int argb)
|
protected static int |
getARGB(int a,
int r,
int g,
int b)
|
protected int |
getB(int argb)
|
static int[][] |
getBlurKernel()
Returns a 3x3 blur kernel. |
java.awt.image.BufferedImage |
getBufferedImage()
|
static int[][] |
getEdgeKernel()
|
static int[][] |
getEmbossKernel()
|
protected int |
getG(int argb)
|
static int[][] |
getGaussianBlurKernel()
Returns a 3x3 gaussian blur kernel. |
java.awt.Graphics |
getGraphics()
Allows standard AWT drawing on the buffer. |
protected int[] |
getImageOffsets()
Reads the first line of the contained image to determine subimages offsets |
protected int |
getR(int argb)
|
static int[][] |
getSharpenKernel()
|
private void |
initPixelArrays()
Saves initial pixels. |
void |
interleave(CImageProcessor imgProcessor,
int[][] mask)
|
void |
invert()
Video inversion of the image. |
void |
mul(java.awt.Color mulColor)
|
void |
mul(int iR,
int iG,
int iB)
|
void |
mul(int iA,
int iR,
int iG,
int iB)
|
void |
restablishTransparency()
|
void |
rotate(float alpha)
Comodity function, performs a rotation from the center of the image. |
void |
rotate(float alpha,
float x,
float y)
Rotates the image. |
int |
safeComponent(int component)
|
void |
saveCurrentPixels()
Saves the current pixels for later use (image restoring or other) |
void |
scrollH(float dx)
|
void |
setAlpha(int alpha)
Modifies the alpha value of the pixels |
java.awt.image.BufferedImage[] |
split()
Splits the contained image in subimmages according to markers contained in the first line. |
protected java.awt.image.BufferedImage[] |
split(int[] offsets)
/** Splits the contained image in subimmages according to an array of offsets. |
void |
wave(float f,
float t)
|
void |
zoom(float lambda)
Comodity function, performs a zoom from the center of the image. |
void |
zoom(float lambda,
float x,
float y)
Zooms the image in or out. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int A_OFFSET
public static final int R_OFFSET
public static final int G_OFFSET
public static final int B_OFFSET
public static final int BYTE_MASK
public static final int RGB_MASK
public static final int A_MASK
public static final int R_MASK
public static final int G_MASK
public static final int B_MASK
protected final java.awt.image.BufferedImage m_bufferedImage
protected int[] m_aBasePixels
private int[] m_aProcessedPixels
public final int W
public final int H
protected final int SCAN_SIZE
private final int NB_PIXELS
private int m_param
Constructor Detail |
---|
public CImageProcessor(int w, int h, boolean bCompatible)
public CImageProcessor(int w, int h)
w
- image widthh
- image heightpublic CImageProcessor(java.awt.Image img)
img
- the Imagepublic CImageProcessor(CImageProcessor rhs)
rhs
- Method Detail |
---|
public java.awt.image.BufferedImage getBufferedImage()
public static final java.awt.image.BufferedImage createCompatibleImage(int w, int h)
w
- BufferedImage's widthh
- BufferedImage's height
public static final java.awt.image.BufferedImage createARGBImage(int w, int h)
w
- BufferedImage's widthh
- BufferedImage's height
protected static final int getARGB(int a, int r, int g, int b)
public java.awt.Graphics getGraphics()
public void saveCurrentPixels()
private final void initPixelArrays()
public void drawImage(java.awt.Graphics g, int x, int y)
g
- x
- y
- public void setAlpha(int alpha)
alpha
- the new alpha valuepublic void colorFilter(java.awt.Color color, boolean bSavePixels)
color
- bSavePixels
- wether to save pixels after operationpublic void colorAdd(java.awt.Color color, boolean bSavePixels)
color
- bSavePixels
- public void scrollH(float dx)
dx
- public final void rotate(float alpha)
alpha
- angle by witch to rotate.public final void rotate(float alpha, float x, float y)
alpha
- angle by witch to rotate.x
- coordinate of the center of the rotation.y
- coordinate of the center of the rotation.public final void zoom(float lambda)
lambda
- zooming factorpublic final void zoom(float lambda, float x, float y)
lambda
- zooming factorx
- center point of the zoomy
- public final void affineTransform(CAffineTransform transform)
transform
- the transformation matrix (containing fixed point values)CAffineTransform
,
CFixedPoint
public final void affineTransformAA(CAffineTransform transform)
transform
- the transformation matrix to be applied.public void convolve(int[][] fpKernel)
fpKernel
- an (m, n) matrix of fixed point values.public int safeComponent(int component)
public void wave(float f, float t)
f
- t
- protected final int[] getImageOffsets()
protected final java.awt.image.BufferedImage[] split(int[] offsets)
offsets
- the said array
public final java.awt.image.BufferedImage[] split()
public final void mul(java.awt.Color mulColor)
public final void mul(int iR, int iG, int iB)
public final void mul(int iA, int iR, int iG, int iB)
public final void invert()
protected final int getA(int argb)
protected final int getR(int argb)
protected final int getG(int argb)
protected final int getB(int argb)
public final void restablishTransparency()
public static final int[][] getBlurKernel()
public static final int[][] getGaussianBlurKernel()
public static final int[][] getEdgeKernel()
public static final int[][] getEmbossKernel()
public static final int[][] getSharpenKernel()
private final int colorLerp(int fpX, int color1, int color2)
fpX
- the ratio in fixed point value. Must belongs to [0, 1].color1
- start colorcolor2
- end color
CFixedPoint
public final void fourCornersGradient(int topLeftColor, int topRightColor, int bottomRightColor, int bottomLeftColor)
topLeftColor
- topRightColor
- bottomRightColor
- bottomLeftColor
- CFixedPoint
public void interleave(CImageProcessor imgProcessor, int[][] mask)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |