when I rotate the image in the imageview it becomes cuted from the corners, this is the function of rotating the image , I work with BufferedImage then I convert it to Image :
public BufferedImage rotate(BufferedImage bImage, int angle) {
int w = bImage.getWidth();
int h = bImage.getHeight();
AffineTransform transform = AffineTransform.getRotateInstance(Math.toRadians(angle), w / 2, h / 2);
AffineTransformOp op = new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR);
BufferedImage bImage2 = new BufferedImage(w, h, BufferedImage.TYPE_INT_ARGB);
op.filter(bImage, bImage2);
}
int a = bImage2.getWidth();
int b = bImage2.getHeight();
view.setFitWidth(a);
view.setFitHeight(b);
return bImage2;
}
and this is the code of rotating button where I put the rotated image in the imageview :
@FXML
private void rotation15(ActionEvent event) throws IOException {
BufferedImage img2 = rotate(grp_img.get(0), 15);
view.setImage(convert(img2)));
}
what should I do ? help me please !!!!
Not tested, but try
BufferedImage bImage2 = op.createCompatibleDestImage(bImage, null);
op.filter(bImage, bImage2);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.