[英]How to display image after using setRGB(x,y,0) in Java?
for(int x=0;x<20;x++)
{
for(int y=0;y<20;y++)
{
img.setRGB(x, y,0);
}
}
I'm trying to convert all pixels in a 20*20 region to black colour. 我正在尝试将20 * 20区域中的所有像素都转换为黑色。 But this is not working with the above code.
但这不适用于上面的代码。 Do i need to add anything more?
我还需要添加更多内容吗?
try this 尝试这个
int rgb=new Color(0,0,0).getRGB(); // i believe rgb for black is 0,0,0 but cross check
for(int x=0;x<20;x++){
for(int y=0;y<20;y++){
img.setRGB(x, y,rgb);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.