2 回答
TA贡献2037条经验 获得超6个赞
这是对我有用的(从这里到那里复制副本):
public BufferedImage rotateImag (BufferedImage imag, int n) { //n rotation in gradians
double rotationRequired = Math.toRadians (n);
double locationX = imag.getWidth() / 2;
double locationY = imag.getHeight() / 2;
AffineTransform tx = AffineTransform.getRotateInstance(rotationRequired, locationX, locationY);
AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_BILINEAR);
BufferedImage newImage =new BufferedImage(imag.getWidth(), imag.getHeight(), imag.getType()); //20, 20 is a height and width of imag ofc
op.filter(imag, newImage);
//this.img = newImage;
return(newImage);
}
添加回答
举报