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
   Programs
(Moderators: fry, REAS)
   compile error but works in authoring mode
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: compile error but works in authoring mode  (Read 485 times)
toxi

WWW
compile error but works in authoring mode
« on: Apr 1st, 2003, 7:20pm »

hi peeps,
 
i wrote a little alpha blending class which works fine when running the sketch via CTRL+R, however it throws a compile error when trying to export. no further details. could you please let me know what i'm doing wrong here - or maybe it's not even me?
 
Code:
FastBlend fb;
BImage    img;
color     c;
 
void setup() {
  size(200,200);
  fb=new FastBlend();
  c=color(255,0,0);
  img=loadImage("test.jpg");
}
 
void loop() {
  int yy;
  for(int y=0; y<200; y++) {
    yy=y*width;
    for(int x=0; x<200; x++) {
      pixels[yy+x]=fb.blend(img.pixels[yy+x],0.8+(float)mouseX/width,mouseX<<16|mouseY<<8|x,(float)y/height);
    }
  }
}
 
// fast alpha blending class with build-in color clipping
// uses 5% blending steps
 
class FastBlend {
  private int table[][] = new int[21][256];
  FastBlend() {
    float blend=0;
    for(int i=0; i<21; i++) {
      for(int j=0; j<256; j++) {
        this.table[i][j]=(int)(blend*j);
      }
      blend+=0.05;
    }
  }
  // remove comments below to see overloading fail
  /*color blend(color c1, float b1, color c2, float b2) {
    int[] t1=table[(int)(b1*20)];
    int[] t2=table[(int)(b2*20)];
    return color(
    min(t1[(int)red(c1)]  +t2[(int)red(c2)],0xff)<<16,
    min(t1[(int)green(c1)]+t2[(int)green(c2)],0xff)<<8,
    min(t1[(int)blue(c1)] +t2[(int)blue(c2)],0xff)
    );
  }*/
 
  int blend(int c1, float b1, int c2, float b2) {
    int[] t1=table[(int)(min(b1,1)*20)];
    int[] t2=table[(int)(min(b2,1)*20)];
    return min(t1[(c1>>16)&0xff] +t2[(c2>>16)&0xff],0xff)<<16 |
    min(t1[(c1>>8)&0xff]  +t2[(c2>>8)&0xff],0xff)<<8 |
    min(t1[c1&0xff]       +t2[c2&0xff],0xff);
  }
}

 
 
also, 2 more "issues"...
 
1) why can't i overload methods, i.e. i wrote a blend() method for either using integers or color params. if i remove the comments, i get a "Duplicate declaration of method" error..?!
 
2) the editor doesn't show a text cursor in 0052 under W2k... is that a know issue?
 
thanks for any answers & ROCK ON!
 
toxi.
« Last Edit: Apr 1st, 2003, 7:21pm by toxi »  

http://toxi.co.uk/
pollux

WWW Email
Re: compile error but works in authoring mode
« Reply #1 on: Apr 1st, 2003, 8:01pm »

i just copy/paste/export/saw it, and it worked smoothly. here it is WIN_XP/P5 0052/JAVA1.4.1_02  
 
i posted it here:
 
http://www.00forward.com/else/fastblend/
 
as for the third issue, welcome to the club. read here:
 
http://proce55ing.net/discourse/yabb/board_Proce55ing_software__bugs_action_display_num_1041962296.html
 
cheers,
« Last Edit: Apr 1st, 2003, 8:32pm by pollux »  

pollux | www.frwrd.net
fry


WWW
Re: compile error but works in authoring mode
« Reply #2 on: Apr 2nd, 2003, 3:18am »

on Apr 1st, 2003, 7:20pm, toxi wrote:
1) why can't i overload methods, i.e. i wrote a blend() method for either using integers or color params. if i remove the comments, i get a "Duplicate declaration of method" error..!

the graphics engine has an internal method called 'blend', so it gets upset when you try to make your own of the same name. kinda shitty, we should probably not have an internal method like that use such a generic name.
 
toxi

WWW
Re: compile error but works in authoring mode
« Reply #3 on: Apr 2nd, 2003, 12:56pm »

hi pollux & ben, thanks for the info...
 
strangely enough i'm able to export your version of the code on my machine now too. i guess the import statements made all the difference...
 
re: internal blend() method & overloading - i just found out what the problem was! somehow the "color" data type seems to be (internally at least) equal to type "int", therefore overloading really has to fail as the arguments used in both versions of the method are identical. could you please shed some more light on the structure of "color"?
 
cheers!
 

http://toxi.co.uk/
fry


WWW
Re: compile error but works in authoring mode
« Reply #4 on: Apr 4th, 2003, 5:05pm »

yeah, internally it's an int, the color values are packed into 32 bits.. this is discussed somewhere else on the bboard (if you want more details), i've lost the reference tho..
 
also, i've renamed the "blend" function in rev 53 to be something less standard so it won't conflict and confuse like this.
 
Pages: 1 

« Previous topic | Next topic »