setRGB() in java

匿名 (未验证) 提交于 2019-12-03 00:56:02

问题:

I am using setRGB() for changing the values of the pixel of an image.

int rgb=new Color(0,0,0).getRGB(); image1.setRGB(i,j,rgb); //where i,j is the boundaries of the image 

Here,i am setting all the pixel values with white. But the change is not getting reflected in the image. Any One knows about the setRGB() how it works?

回答1:

White is in RGB 255,255,255 so:

Color myWhite = new Color(255, 255, 255); // Color white int rgb = myWhite.getRGB();  try {     BufferedImage img = null;     try {         img = ImageIO.read(new File("bubbles.bmp"));     }     catch (IOException e) {     }      for (int i = 0; i 


回答2:

 Color col = new Color(newValue, newValue, newValue);             image1.setRGB(i, j, col.getRGB()); 


文章来源: setRGB() in java
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!