Java:旋转图像
问题描述:
我需要能够单独旋转图像(在Java中)。到目前为止,我发现的唯一东西是g2d.drawImage(image,affinetransform,ImageObserver)。不幸的是,我需要在特定点绘制图像,并且没有一种方法带有参数1.分别旋转图像和2.允许我设置x和y。任何帮助表示赞赏
第 1 个答案:
这就是你可以做到的。这段代码假设存在一个名为“ image”的缓冲图像(如你的评论所说)
// The required drawing location int drawLocationX = 300; int drawLocationY = 300; // Rotation information double rotationRequired = Math.toRadians (45); double locationX = image.getWidth() / 2; double locationY = image.getHeight() / 2; AffineTransform tx = AffineTransform.getRotateInstance(rotationRequired, locationX, locationY); AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR); // Drawing the rotated image at the required drawing locations g2d.drawImage(op.filter(image, null), drawLocationX, drawLocationY, null);
我需要找出一种将带有java.util.Date字段的记录插入数据库的方法,但我陷入了困境。有谁知道我该怎么做?现在我有类似的东西。 java.util.Date myDate = new java.util ...