本文整理汇总了Java中javax.microedition.lcdui.game.Sprite.TRANS_MIRROR_ROT270属性的典型用法代码示例。如果您正苦于以下问题:Java Sprite.TRANS_MIRROR_ROT270属性的具体用法?Java Sprite.TRANS_MIRROR_ROT270怎么用?Java Sprite.TRANS_MIRROR_ROT270使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类javax.microedition.lcdui.game.Sprite
的用法示例。
在下文中一共展示了Sprite.TRANS_MIRROR_ROT270属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createImage
/**
* Creates a new image based upon the transformed region of another image
* @param image Source image
* @param x x co-ordinate of the source region
* @param y y co-ordinate of the source region
* @param w width of the source region
* @param h height of the source region
* @param transform Transform to be applied
* @return New image
* @see Graphics#drawRegion(javax.microedition.lcdui.Image, int, int, int, int, int, int, int, int)
* #see game.Sprite
*/
public static Image createImage(Image image, int x, int y, int w, int h, int transform)
{
int ow = w;
int oh = h;
// Work out what shape the new image will be...
switch (transform)
{
case Sprite.TRANS_MIRROR:
case Sprite.TRANS_MIRROR_ROT180:
case Sprite.TRANS_ROT180:
case Sprite.TRANS_NONE:
break;
case Sprite.TRANS_MIRROR_ROT270:
case Sprite.TRANS_MIRROR_ROT90:
case Sprite.TRANS_ROT270:
case Sprite.TRANS_ROT90:
ow = h;
oh = w;
break;
}
// Create empty new image
Image newImage = createImage(ow, oh);
Graphics g = newImage.getGraphics();
g.drawRegion(image, x, y, w, h, transform, 0, 0, 0);
return newImage;
}
示例2: createImage
public Image createImage(Image image, int x, int y, int width, int height, int transform) {
// TODO AndroidDisplayGraphics.drawRegion code is similar
if (image == null)
throw new NullPointerException();
if (x + width > image.getWidth() || y + height > image.getHeight() || width <= 0 || height <= 0 || x < 0
|| y < 0)
throw new IllegalArgumentException("Area out of Image");
Bitmap img;
if (image.isMutable()) {
img = ((AndroidMutableImage) image).getBitmap();
} else {
img = ((AndroidImmutableImage) image).getBitmap();
}
Matrix matrix = new Matrix();
switch (transform) {
case Sprite.TRANS_NONE: {
break;
}
case Sprite.TRANS_ROT90: {
matrix.preRotate(90);
break;
}
case Sprite.TRANS_ROT180: {
matrix.preRotate(180);
break;
}
case Sprite.TRANS_ROT270: {
matrix.preRotate(270);
break;
}
case Sprite.TRANS_MIRROR: {
matrix.preScale(-1, 1);
break;
}
case Sprite.TRANS_MIRROR_ROT90: {
matrix.preScale(-1, 1);
matrix.preRotate(-90);
break;
}
case Sprite.TRANS_MIRROR_ROT180: {
matrix.preScale(-1, 1);
matrix.preRotate(-180);
break;
}
case Sprite.TRANS_MIRROR_ROT270: {
matrix.preScale(-1, 1);
matrix.preRotate(-270);
break;
}
default:
throw new IllegalArgumentException("Bad transform");
}
return new AndroidImmutableImage(Bitmap.createBitmap(img, x, y, width, height, matrix, true));
}