public final class JMEImageUtils
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static int |
BASIC_ONE_POINT_PICK
The fastest scaling algorithm, this pulls one pixel from the source image
to the destination image, thus decimating the image to make it smaller.
|
static int |
FIVE_POINT_BLEND
Although just slightly slower than ONE_POINT_PICK, this algorithm does a
log more by combing a weighted sampling 5 pixels from the source image to
generate each resized image pixel.
|
static int |
ONE_POINT_PICK
This is BASIC_ONE_POINT_PICK slightly modified to improve the legibility
when scaling down to very small sizes.
|
static int |
WEIGHTED_AVERAGE_OPAQUE
This algorithm combines the relative contributions of all source pixels
with appropriate weighting.
|
static int |
WEIGHTED_AVERAGE_TRANSLUCENT
This is the weighted average combination of pixels algorithm including
alpha channel blending to produce scaled translucent images for layering
effects.
|
Constructor and Description |
---|
JMEImageUtils() |
Modifier and Type | Method and Description |
---|---|
static void |
drawFlipshade(javax.microedition.lcdui.Graphics g,
int x,
int y,
int[] inputImageARGB,
int[] outputImageARGB,
int srcW,
int srcH,
int maxW,
int maxH,
boolean processAlpha)
Draw an image squeezed along the horizontal and/or vertical dimensions
(no preservation of aspect ratio) centered at (x, y).
|
static javax.microedition.lcdui.Image |
scaleImage(javax.microedition.lcdui.Image sourceImage,
int maxW,
int maxH,
boolean preserveAspectRatio,
int scalingAlgorithm)
Convenience class for scaling images.
|
static javax.microedition.lcdui.Image |
scaleImage(int[] inputImageARGB,
int[] outputImageARGB,
int srcW,
int srcH,
int maxW,
int maxH,
boolean preserveAspectRatio,
int scalingAlgorithm)
Return an image which is, if needed to fit inside a bounding box,
down-scaled and smaller then the original on one or both axes.
|
public static final int FIVE_POINT_BLEND
public static final int BASIC_ONE_POINT_PICK
public static final int ONE_POINT_PICK
public static final int WEIGHTED_AVERAGE_OPAQUE
public static final int WEIGHTED_AVERAGE_TRANSLUCENT
public static javax.microedition.lcdui.Image scaleImage(javax.microedition.lcdui.Image sourceImage, int maxW, int maxH, boolean preserveAspectRatio, int scalingAlgorithm)
sourceImage
- maxW
- - use Integer.MAX_VALUE if you do not want to scale by widthmaxH
- - use Integer.MAX_VALUE if you do not want to scale by heightpreserveAspectRatio
- - set false to shrink by different amounts on
each axis, but not more than needed to fit in the bounding box specified
by maxW and maxHscalingAlgorithm
- public static javax.microedition.lcdui.Image scaleImage(int[] inputImageARGB, int[] outputImageARGB, int srcW, int srcH, int maxW, int maxH, boolean preserveAspectRatio, int scalingAlgorithm)
synchronized (Task.LARGE_MEMORY_MUTEX) { final int[] data = new int[w * h]; image.getRGB(data, 0, w, 0, 0, w, h); image = null; image = JMEImageUtils.scaleImage(data, data, w, h, maxW, maxH, true, false, false); }
inputImageARGB
- - ARGB data for the original imageoutputImageARGB
- - ARGB data buffer for the scaled image, can be
the same as inputImageARGB if downscaling (faster)srcW
- - Source image widthsrcH
- - Source image heightmaxW
- - maximum (bounding box, will not upscale) width of scaled
imagemaxH
- - maximum (bounding box, will not upscale) height of scaled
imagepreserveAspectRatio
- - set true except for special effectsscalingAlgorithm
- - a constant from JMEImageUtils specifying how to
scalepublic static void drawFlipshade(javax.microedition.lcdui.Graphics g, int x, int y, int[] inputImageARGB, int[] outputImageARGB, int srcW, int srcH, int maxW, int maxH, boolean processAlpha)
g
- - object to draw ontox
- - horizontal center of where to draw the resulting imagey
- - vertical center of where to draw the resulting imageinputImageARGB
- outputImageARGB
- - often this is the same as inputImageARGB for
speedsrcW
- - source image widthsrcH
- - source image heightmaxW
- - target widthmaxH
- - target heightprocessAlpha
- - set false for speed if the image is opaque