title: Change the color of each pixel in an image java
body: <p>I wanna change different pixel to different color. Basically, change part of pixel to transparent. </p>
  
  <pre><code>for(int i = 0; i &lt; image.getWidth();i++)
          for(int j = 0; j &lt; image.getHeight(); j ++)
          {
              image.setRGB(i,j , 0);
          }
  </code></pre>
  
  <p>//I aslo change the third parameter 0 to another attribute. but it still does not work. it all show black. do you have some ideas?</p>
  
  <p>yin.
  thanks </p>
  
  <pre><code>class ImagePanel extends JPanel {
  
      private BufferedImage image;
  
      public ImagePanel(int width, int height, BufferedImage image) {
          this.image = image;
          image = new BufferedImage(width, height,
                  BufferedImage.TYPE_INT_ARGB);
          repaint();
      }
  
      /**
       * Draws the image.
       */
  
      public void paintComponent(Graphics g) {
          super.paintComponent(g);
          for (int i = 0; i &lt; image.getWidth(); i++) {
              for (int j = 0; j &lt; image.getHeight(); j++) {
                  image.setRGB(i, j, 0);
              }
          }
          g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
  
      }
  
  }
  </code></pre>