我正在尝试旋转a BufferedImage并将其显示在a JLabel(位于内JPanel)中。当前结果产生一个白色正方形,相对于黑色背景旋转了10度,但正方形内部不存在图像。我知道myPicture不是空白,因为myPicture它本身JPanel在未旋转时会正确显示在内。
这是代码:
int w = myPicture.getWidth();
int h = myPicture.getHeight();
BufferedImage newImage = new BufferedImage(w, h, myPicture.getType());
Graphics2D graphic = newImage.createGraphics();
graphic.rotate(Math.toRadians(10), w/2, h/2);
graphic.drawImage(myPicture, null, 0, 0);
picLabel.setIcon(new ImageIcon(newImage));
幕布斯6054654
相关分类