怎样写J2ME代码使图片旋转

 我来答
_静静的思考
2010-11-09 · 超过18用户采纳过TA的回答
知道答主
回答量:51
采纳率:0%
帮助的人:59万
展开全部
public void drawRegion(Image src,//图片对象
int x_src,//图片的坐标
int y_src,//图片的坐标
int width,//图片的宽
int height,//图片的高
int transform,//翻转角度
int x_dest,//目的地的坐标
int y_dest,
int anchor)//锚点

Copies a region of the specified source image to a location within the destination, possibly transforming (rotating and reflecting) the image data using the chosen transform function.

The destination, if it is an image, must not be the same image as the source image. If it is, an exception is thrown. This restriction is present in order to avoid ill-defined behaviors that might occur if overlapped, transformed copies were permitted.

The transform function used must be one of the following, as defined in the Sprite class:
Sprite.TRANS_NONE - causes the specified image region to be copied unchanged
Sprite.TRANS_ROT90 - causes the specified image region to be rotated clockwise by 90 degrees.
Sprite.TRANS_ROT180 - causes the specified image region to be rotated clockwise by 180 degrees.
Sprite.TRANS_ROT270 - causes the specified image region to be rotated clockwise by 270 degrees.
Sprite.TRANS_MIRROR - causes the specified image region to be reflected about its vertical center.
Sprite.TRANS_MIRROR_ROT90 - causes the specified image region to be reflected about its vertical center and then rotated clockwise by 90 degrees.
Sprite.TRANS_MIRROR_ROT180 - causes the specified image region to be reflected about its vertical center and then rotated clockwise by 180 degrees.
Sprite.TRANS_MIRROR_ROT270 - causes the specified image region to be reflected about its vertical center and then rotated clockwise by 270 degrees.

If the source region contains transparent pixels, the corresponding pixels in the destination region must be left untouched. If the source region contains partially transparent pixels, a compositing operation must be performed with the destination pixels, leaving all pixels of the destination region fully opaque.

The (x_src, y_src) coordinates are relative to the upper left corner of the source image. The x_src, y_src, width, and height parameters specify a rectangular region of the source image. It is illegal for this region to extend beyond the bounds of the source image. This requires that:
/* 这是参数要求。*/
x_src >= 0
y_src >= 0
x_src + width <= source width//图片的大小
y_src + height <= source height

The (x_dest, y_dest) coordinates are relative to the coordinate system of this Graphics object. It is legal for the destination area to extend beyond the bounds of the Graphics object. Pixels outside of the bounds of the Graphics object will not be drawn.

The transform is applied to the image data from the region of the source image, and the result is rendered with its anchor point positioned at location (x_dest, y_dest) in the destination.

Parameters:
src - the source image to copy from
x_src - the x coordinate of the upper left corner of the region within the source image to copy
y_src - the y coordinate of the upper left corner of the region within the source image to copy
width - the width of the region to copy
height - the height of the region to copy
transform - the desired transformation for the selected region being copied
x_dest - the x coordinate of the anchor point in the destination drawing area
y_dest - the y coordinate of the anchor point in the destination drawing area
anchor - the anchor point for positioning the region within the destination image
Throws:/*异常信息*/
IllegalArgumentException - if src is the same image as the destination of this Graphics object
NullPointerException - if src is null
IllegalArgumentException - if transform is invalid
IllegalArgumentException - if anchor is invalid
IllegalArgumentException - if the region to be copied exceeds the bounds of the source image

参考资料: 来源是:midp api 2.0

百度网友812356a
2010-10-28 · 超过35用户采纳过TA的回答
知道答主
回答量:148
采纳率:0%
帮助的人:93.9万
展开全部
可以将图片放到Sprite中,然后利用Sprite.TRANS_ROT90(180,270) 来旋转
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式