FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Programming Questions & Help
   Syntax
(Moderators: fry, REAS)
   Newbie has his arrays flooding.
« Previous topic | Next topic »

Pages: 1 
   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.
 
fjen

WWW
Re: Newbie has his arrays flooding.
« Reply #1 on: Dec 2nd, 2004, 1:36am »

i don't really understand what you are trying to do ... every BImage already has an array of pixels containing the image. in fact that's what the image is.
 
BImage yourimage = loadImage("my640_480.jpg");
println(yourimage.pixels.length); // will give you 640*480 = 307200 //
 
looks like you are trying to store bits
19200*16 = 307200
 
look into color to see what the values in pixels are:
http://processing.org/reference/color.html
 
here's some more on the nature of ARGB:
http://processing.org/discourse/yabb/board_Programs_action_disp_lay_num_1099892081.html
 
/F
 
Pages: 1 

« Previous topic | Next topic »