Q
Q
Quad_Tree2015-07-27 16:53:19
Java
Quad_Tree, 2015-07-27 16:53:19

How to write an array of pixels to an image in Java?

I have a PNG image 200x100 pixels. And in it I need to write an array of pixels 200x100 (values ​​​​with a certain rgb color). How can this be implemented?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evhen, 2015-07-27
@Quad_Tree

public static void main(String[] args) throws IOException {
    
    BufferedImage png = ImageIO.read(new File("image.png"));
    
    Color color = new Color(0, 0, 0);
    
    png.setRGB(2, 2, color.getRGB());
    
    ImageIO.write(png, "png", new File("image.png"));

  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question