|
Author |
Topic: Newbie has his arrays flooding. (Read 307 times) |
|
klaivu
|
Newbie has his arrays flooding.
« on: Dec 1st, 2004, 1:42pm » |
|
Hello. Trying to store a 640*480 image into an array. I'm fairly sure there's a smarter way to do this, but I would like to understand what I'm doing wrong. And I expect it's a lot of things. The source: void setup(){ size(640, 480); } void muunna(){ BImage lahde_img; lahde_img = loadImage("sota_bw.jpg"); int[][] img_palaset = new int[19200][16]; int i; i = 0; int i2; i2 = 0; int i_x; i_x = 0; int i_y; i_y = 0; int rbg; rbg = 0; int index; index = 0; BImage i_img = get(0,0,4,4); while(i<=19199) { while(i2<=15){ index = i_y*640 + i_x; i_img.pixels[i2] = lahde_img.pixels[index]; if(i_x%4==0){ i_y = i_y + 1; i_x = i_x - 4; } i_x = i_x + 1; i2 = i2 + 1; } i_x = i_x + 4; i2 = 0; while(i2<=15) { img_palaset[i][i2] = int(3 * red(i_img.pixels[i2]) + .6 * green(i_img.pixels[i2]) + .1 * blue(i_img.pixels[i2])); i2 = i2 + 1; } i2 = 0; i = i + 1; } I thank you in advance.
|
|
|
|
|