[英]Error At Drawing A Bufferedimage In Java
I am trying to draw a BufferedImage
using Java graphics. 我正在尝试使用Java图形绘制BufferedImage
。 In my previous experiences, it worked many times, but now I don't know why eclipse is giving me an error. 根据我以前的经验,它多次运行,但是现在我不知道为什么月食给我一个错误。
It gives me this error: 它给了我这个错误:
The method drawImage(BufferedImage, int, int, null) is undefined for the type Graphics 对于Graphics类型,未定义方法drawImage(BufferedImage,int,int,null)
public void render(Graphics g){
g.drawImage(ss1[1],30,80,null);
}
In the above code, ss1[]
is an array of BufferedImage
在上面的代码中, ss1[]
是BufferedImage
的数组
That error means that there is not a method with that signature. 该错误意味着没有带有该签名的方法。
Are you sure there is a drawImage
that accepts a BufferedImage
, an int
, another int
and Object
? 您确定有一个drawImage
接受BufferedImage
,一个int
,另一个int
和Object
吗?
There is a method drawImage(Image, int, int, ImageObserver)
in Graphics - which should match your call as pointed out by @MadProgrammer. 在Graphics中有一个方法drawImage(Image, int, int, ImageObserver)
-应该与@MadProgrammer指出的调用相匹配。
I suggest you try to call Graphics2D#drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
. 我建议您尝试调用Graphics2D#drawImage(BufferedImage img, BufferedImageOp op, int x, int y)
。
As Graphics is usually a Graphics2D, you should be able to call 由于Graphics通常是Graphics2D,因此您应该可以调用
((Graphics2D)g).drawImage(ss1[1],null, 30,30);
While I am unsure if you can leave the ImageOp null. 虽然我不确定是否可以将ImageOp保留为空。
Hm, but maybe your issue is rather the same as this person's? 嗯,但也许您的问题与此人的问题完全相同? Can't draw a Buffered Image 无法绘制缓冲图像
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.