title: generating a new image using a transformer class java
body: <p>I am using a transformer class in order to generate a new image with modified pixels. Basically I am iterating over each pixel in the original image, then applying the given transformation (ex. color inversion, contrast, etc.) in order to generate a new picture. I'm not really sure how to approach this problem...this is what I have so far.</p>
  
  <pre><code>public static NewPicture transform(NewPicture p, Transformer t) {
  int w = p.getWidth();
  int h = p.getHeight();
  
  Pixel[][] src = getBitmap();
  Pixel[][] tgt = new Pixel[w][h];
  
  for (int x = 0; x &lt; w; x++) {
    for (int y = 0; y &lt; h; y++) {
      // Not sure what to do after this nested for loop
  </code></pre>
  
  <p>NewPicture is simply an image represented by a 2D array of Pixels. The interface for my Pixel transformer is </p>
  
  <pre><code>public interface Transformer {
    public Pixel transformPixel (pixel p);
  }
  </code></pre>
  
  <p>It simply creates a new Pixel based on the given RGB components of the input, but does not modify the pixel.</p>
  
  <p>I would appreciate any guidance as to how to approach this problem. Thanks.</p>