Tag: imageobserver

获得正确的图像观察者来旋转图像

所以我画了一个BufferedImage’鸟’,但我想根据它落下的角度旋转它。 我有一个鸟对象,它包含BufferedImage和一个render()方法,它旋转绘制它。 public void render(Graphics2D g, ImageObserver io) { double theta = Math.tan((height – pastHeight) / .875); System.out.println(theta); Graphics2D g2 = (Graphics2D) bird.getGraphics(); g2.drawImage(bird, 100, (int) height, null); g2.rotate(theta); g2.drawImage(bird, 100, (int) height, io); } 我这样称呼它 bird.render(g2, ???); 在我的jcomponent中的paintcomponent方法中。 唯一的问题是我不知道该使用什么作为我的ImageObserver …我已经尝试传递我的JFrame和我的JComponent但是当我这样做时图像不再出现…我会传递什么图像出现在我的窗口和/或我怎么能实现这种旋转?