Downscaling an image to an array

Hello @paulgoux,

This is as far as I got and had fun working through this.

I did not get to down scaling yet… just working through your code.

Code
PImage img;
ArrayList<Integer> array = new ArrayList<Integer>();
int x, y;

void setup()
  {
  size(500, 200);
  img = loadImage("test.png");
  background(255);
  
  for(int y=0; y<img.height; y++)
    {
    for(int x=0; x<img.width; x++)
      {
      int p = int(y*img.width + x);
      if(p<img.pixels.length)
        {
        int r = int(red(img.pixels[p]));
        int g = int(green(img.pixels[p]));
        int b = int(blue(img.pixels[p]));
        int h = (int(r*256*256 + 256*g + b) | 0xFF000000);
        array.add(h);
        //println(r, g, b, hex(array.get(p)));
        stroke(array.get(y*img.width + x));
        point(x, y);
        }
      }      
    }
  noLoop();
  }

void draw()
  {  
  for(int y=0; y<img.height; y++)
    {
    for(int x=0; x<img.width; x++)
      {
      int p = int(y*img.width + x);
      if(p<img.pixels.length)
        {
        //float r = red(img.pixels[p]);
        //float g = green(img.pixels[p]);
        //float b = blue(img.pixels[p]);
        //int h = (int(r*256*256 + 256*g + b) | 0xFF000000);
        //array.add(h);
        //println(r, g, b, hex(array.get(p)));
        stroke(array.get(y*img.width + x));
        point(x+250, y);
        }
      }      
    }
  }

The image I used:
test

:)