当前位置: 首页>>代码示例>>Java>>正文


Java Sprite.TRANS_MIRROR_ROT180属性代码示例

本文整理汇总了Java中javax.microedition.lcdui.game.Sprite.TRANS_MIRROR_ROT180属性的典型用法代码示例。如果您正苦于以下问题:Java Sprite.TRANS_MIRROR_ROT180属性的具体用法?Java Sprite.TRANS_MIRROR_ROT180怎么用?Java Sprite.TRANS_MIRROR_ROT180使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在javax.microedition.lcdui.game.Sprite的用法示例。


在下文中一共展示了Sprite.TRANS_MIRROR_ROT180属性的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;
}
 
开发者ID:SnakeSVx,项目名称:ev3,代码行数:38,代码来源:Image.java

示例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));
}
 
开发者ID:Helltar,项目名称:AMPASIDE,代码行数:57,代码来源:AndroidDeviceDisplay.java


注:本文中的javax.microedition.lcdui.game.Sprite.TRANS_MIRROR_ROT180属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。