Set BufferedImage to be a color in Java

前端 未结 5 947
既然无缘
既然无缘 2021-01-07 19:52

I need to create a rectangular BufferedImage with a specified background color, draw some pattern on the background and save it to file. I don\'t know how to cr

5条回答
  •  囚心锁ツ
    2021-01-07 20:26

    BufferedImage image = new BufferedImage(width,height, BufferedImage.TYPE_INT_ARGB);
    int[]data=((DataBufferInt) image.getRaster().getDataBuffer()).getData();
    Arrays.fill(data,color.getRGB());
    

提交回复
热议问题