java - Get transparency of a bufferedimage -


i want change blue color of image. use code chage it.

int i, j, red, green, blue;         for(i = 0; < 64; i++){             for(j = 0; j < 64; j++){                 color c = new color(brimage.getrgb(i, j));                 red = c.getred();                 green = c.getgreen();                 blue = c.getblue();                 int rgb = new color(0, 255, 0).getrgb();                 if(red == 0 && green == 0 && blue == 178){                     brimage.setrgb(i, j, rgb);                 }             }         } 

the problem is change color of transparent areas instead of blue areas. how fix this?

you need include current pixels alpha level...

int i, j, red, green, blue, alpha; for(i = 0; < 64; i++){     for(j = 0; j < 64; j++){         color c = new color(brimage.getrgb(i, j));         red = c.getred();         green = c.getgreen();         blue = c.getblue();         alpha = c.getalpha(); // include me...         int rgb = new color(0, 255, 0, alpha).getrgb();         if(red == 0 && green == 0 && blue == 178){             brimage.setrgb(i, j, rgb);         }     } } 

Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -