|
1.0: Final Release | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ImageTransformControl
is used to crop, zoom, mirror,
flip, stretch and rotate images. The application may specify a source
rectangle that is mapped to a new image whose size may be
specified.
Initially, the source rectangle consists of the whole image and
the target image size is equivalent to the original size. So, if these rectangles are
not altered, the control does not modify the image in any way. The size of the original image
can be queried by getSourceWidth
and getSourceHeight
methods.
The tranformation is modeled so that the processed image is placed on top of a very large black image.
The upper left corner of the processed image is in (0,0) and the lower right corner is in
(width-1,height-1). setSourceRect
takes the starting point coordinates and the
width and height vector of the area that is intended to be transformed. A negative width and/or height will
flip the image vertically and/or horisontally. The source area can contain black pixels outside
the processed image.
For clarity, the black pixels outside the processed image are grey in this figure.
After the stretching operation, the resulting image may be rotated by a multiple of 90 degrees.
processor
is the MediaProcessor
the input has been set.
String controlName = "javax.microedition.amms.control.imageeffect.ImageTransformControl"; ImageTransformControl transform = processor.getControl(controlName); int origWidth = transform.getSourceWidth(); int origHeight = transform.getSourceHeight();
// add 50 pixel wide black frames around the picture transform.setSourceRect( -50, -50, origWidth + 2 * 50, origHeight + 2 * 50); transform.setTargetSize( origWidth + 2 * 50, origHeight + 2 * 50, 0);
OverlayControl
could be used to add nicer looking frames on top of the produced black frames.
// stretch to 100 * 100 pixels bigger image by setting the target width and height to original + 100 transform.setSourceRect( 0, 0, origWidth, origHeight); transform.setTargetSize( origWidth + 100, origHeight + 100, 0);
// for vertical flip y = origHeight and height is negative transform.setSourceRect( 0, origHeight, origWidth, -origHeight); transform.setTargetSize( 0, 0, 0); // using 0 as width and height retain the original image size
Field Summary |
Fields inherited from interface javax.microedition.amms.control.EffectControl |
SCOPE_LIVE_AND_RECORD, SCOPE_LIVE_ONLY, SCOPE_RECORD_ONLY |
Method Summary | |
int |
getSourceHeight()
Returns the height of the source image. |
int |
getSourceWidth()
Returns the width of the source image. |
void |
setSourceRect(int x,
int y,
int width,
int height)
Specifies the source rectangle in pixels. |
void |
setTargetSize(int width,
int height,
int rotation)
Specifies the size and rotation of the resulting image. |
Methods inherited from interface javax.microedition.amms.control.EffectControl |
getPreset, getPresetNames, getScope, isEnabled, isEnforced, setEnabled, setEnforced, setPreset, setScope |
Method Detail |
public int getSourceWidth()
java.lang.IllegalStateException
- if the source image is not setpublic int getSourceHeight()
java.lang.IllegalStateException
- if the source image is not setpublic void setSourceRect(int x, int y, int width, int height)
The default source rectangle is the source image. Therefore, the call of setSourceRect can be omitted if the parameters would be (0, 0, original_width, original_height).
x
- the x-coordinate of the upper left corner of the rectangley
- the y-coordinate of the upper left corner of the rectanglewidth
- the width of the rectangleheight
- the height of the rectangle
java.lang.IllegalArgumentException
- if width
or height
is 0public void setTargetSize(int width, int height, int rotation)
The default target size is the size specified with setSourceRect and the default target rotation is zero degrees. Therefore, the call of setTargetSize can be omitted if the operation to be performed is not shrink, stretch or rotate.
width
- the width of the resulting image. If 0 the width of the source image is used.height
- the height of the resulting image. If 0 the height of the source image is used.rotation
- the rotation of the resulting image, in
multiples of 90 degrees. Positive angles designate clockwise rotation and
negative values designate counterclockwise rotation.
java.lang.IllegalArgumentException
- if width or height is negative
or if they are above certain device-specific
limits or if the rotation angle is not an integer multiple of
90 degrees
|
1.0: Final Release | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |