Invert bitmap colors

前端 未结 4 1390
悲&欢浪女
悲&欢浪女 2021-02-06 11:10

I have the following problem. I have a charting program, and it\'s design is black, but the charts (that I get from the server as images) are light (it actually uses only 5 colo

4条回答
  •  不要未来只要你来
    2021-02-06 12:05

    If you have it available as BufferedImage, you can access its raster and edit it as you please.

    WritableRaster raster = my_image.getRaster();
    
    // Edit all the pixels you wanna change in the raster (green -> red, pink -> green)
    // for (x,y) in ...
    // raster.setPixel(x, y, ...) 
    
    my_image.setData(raster);
    

提交回复
热议问题