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)
   Image background channel conflict?
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Image background channel conflict?  (Read 1294 times)
Xu1

WWW Email
Image background channel conflict?
« on: Jun 3rd, 2003, 10:51pm »

Ok..in version 0046 I had this code as such, to load an image for the background:
BImage bg;
int[]bgPixBlue;
boolean firstTime=true;
float a = .0f;
 
float rect_size;
 
void setup() {
 
  size(450,337);
  background(#C1F1FB);
  bg = loadImage("poimage1.jpg");
  bgPixBlue = new int[pixels.length];
  fill(#C1F1FB);
  rect_size = width/2;
  stroke(#ffffff);
   
 
}
 
void loop() {
  if(firstTime) {
    image(bg,0,0);
    for(int i=0; i<pixels.length; i++) {
 bgPixBlue[i]=pixels[i];
    }
    firstTime=false;
  }
  System.arraycopy(bgPixBlue,0,pixels,0,bgPixBlue.length);
 
  a += 0.01;
 
if(a > TWO_PI) { a = 0.0; }
 
  translate(width/2, height/2);
 
  rotateX(a*7);
 
  rotateY(a*2);
 
  rect(-rect_size, -rect_size, rect_size-0, rect_size-0);
 
  rotateX(a*4.001);
 
  rotateY(a*3.002);
 
  rect(-rect_size, -rect_size, rect_size-0, rect_size-0);
 
  rotateX(a*7);
 
  rotateY(a*2);
 
  rect(-rect_size, -rect_size, rect_size-0, rect_size-0);
 
  rotateX(a*7);
 
  rotateY(a-2);
 
  rect(-rect_size, -rect_size, rect_size-0, rect_size-0);
 
}
But in 0055 there is an apparent conflict with the fill and background colour, as the image is darkened. If I turn background off to noBackground I get only the stroke outline, or sometimes I get no Background at all except for the fill colour??
 
this could be a simple fix..but not for me..
 
Tony
 
arielm

WWW
Re: Image background channel conflict?
« Reply #1 on: Jun 4th, 2003, 12:23am »

the darknening-of-the-image problem is due to the fact that you use fill() before image()...
 
in general, i would not use fill() and stroke() in setup() but rather put them just before rect() or any other graphic operation that consume them (otherwise it's a door open to a lot of weird things that looks like bugs but aren't)
 
in theory, image(BImage, int, int) should not use texture-mapping but it does, and therefore, texture-mapping is tinted by the current color... so to get a normal image: fill(255) will do it...
 
anyway, in your current example, you don't have to use image() at all...
 
apparently, the "boolean firstTime=true" trick is not required anymore, so it's enough to loadImage() in setup() and then, at the beginning of loop(): a simple System.arraycopy() with the image pixels[] will do it...
 
finally, concerning noBackground(): i assume that your bg image has the same size as the canvas, so it should be logical to use noBackground() so we can gain execution speed (processing won't have to clear the whole pixels[] array at the beginning of each frame)...
 
the problem is that noBackground() also means that the "zbuffer" won't be cleared, therefore 3d filled polygon won't redraw correctly...
 
but there's a workaround (could not work in the future) to this: clearing manually the zbuffer!
 
all these suggestions are implemented in the following (it's the modified beginning of the code you post):
 
(it works as intended, in 0054)
 
Code:

BImage bg;  
float a = .0f;  
 
float rect_size;  
 
void setup() {  
  size(450,337);  
  noBackground();  
  bg = loadImage("poimage1.jpg");  
  fill(#C1F1FB);  // a dangerous place...
  rect_size = width/2;  
  stroke(#ffffff);  
}  
 
void loop() {
  int pc = g.pixelCount;  
  float[] zb = g.zbuffer;  
  for (int i = 0; i < pc; i++)  
  {  
    zb[i] = MAX_FLOAT;  
  }
 
  System.arraycopy(bg.pixels,0,pixels,0,bg.pixels.length);
 

Ariel Malka | www.chronotext.org
Xu1

WWW Email
Re: Image background channel conflict?
« Reply #2 on: Jun 4th, 2003, 7:26am »

Thanks Arilem.
 
Actually most of the code was from one of your posts earlier on I just used it for this experiment.
 
It would be good if some time down the track there was some way of adding more functionality to the program like add-ons or plug-ins that would make the repetitive common tasks less tedious, especially for people like me who dont have a masters in quantiscubic algebraic gigonometry...like most of you seem to have...
 
Tony
 
arielm

WWW
Re: Image background channel conflict?
« Reply #3 on: Jun 4th, 2003, 9:20am »

actually, my degree is in post random epistemo autopoesis...
 
(but i'm bad in maths, every one or two year, when i have time between two works _ the freelancer life _ i do some stuff with maths and physics but then i have to remind myself what is an integral, from scratch... and then, i forget again... loop()
 
p.s: so what do we see in "poimage1.jpg"?
 

Ariel Malka | www.chronotext.org
Xu1

WWW Email
Re: Image background channel conflict?
« Reply #4 on: Jun 4th, 2003, 12:47pm »

LOL....Thanks for the help..actually I'm working on my web site and I'm trying a few different effects on my index image for the site. www.pageopen.com
you can see it if you go there. I want to just move away from flash a bit and concentrate on 3d imaging (3ds Max)and photoshop, but a good blend of the unusual mix of stills and random effects are what I'm trying to get. the problem I have is proce55ing_Alpha is relatively new to me and I need time to get around things like programming languages...I actually tried to fill the rects with a gradient but had no success... I see some of the work of Proce55ing members and its really great....good inspiration...
 
Tony
 
arielm

WWW
Re: Image background channel conflict?
« Reply #5 on: Jun 4th, 2003, 2:17pm »

i like the idea of experimental sites that experiment not only with flash...
 
gradients are possible to achieve if you switch to beginShape(POLYGON or QUAD etc.) instead of rect(), and use fill() in parallel to vertex()...
 
i have an advice for your web site: if your index page contains an applet, as it is now, then it might not be a good idea to open a new window for the "main part" because then, any other applet there will run at 50% speed...
 
or maybe, once the new window is openned, something should kill the index applet, e.g. javascript: document.location.replace("foo.htm")
 

Ariel Malka | www.chronotext.org
benelek

35160983516098 WWW Email
Re: Image background channel conflict?
« Reply #6 on: Jun 4th, 2003, 2:43pm »

i have also been thinking about how i could achieve some good web page effects without flash. i think the problem, generally, with using a java applet in the starter page is that it takes a short while to load up... in which people become agitated. i think someone else on the bboard mentioned the need for some kind of "loading" sign or something. to me this is a significant advantage of flash over p5 or java...
 
Would anybody know how to create a simple loop to display while the applet is loading? such effects could probably be done using javascript, etc, but it would be much better if the applet itself could to it. is this possible?
 
on a less focussed sidenote, Tony would you happen to be another SydneySider? i had a quick look around your site, and noticed the phone number down the bottom, complete with the sydney/NSW area code!
 
Xu1

WWW Email
Re: Image background channel conflict?
« Reply #7 on: Jun 4th, 2003, 10:29pm »

on Jun 4th, 2003, 2:17pm, arielm wrote:

 
i have an advice for your web site: if your index page contains an applet, as it is now, then it might not be a good idea to open a new window for the "main part" because then, any other applet there will run at 50% speed...
 

 
Thanks Arielm...You would not believe how many times I open up dreamweaver to do this but end up doing something else and forgetting about it....even last night...
 
Tony
« Last Edit: Jun 4th, 2003, 10:38pm by Xu1 »  
Xu1

WWW Email
Re: Image background channel conflict?
« Reply #8 on: Jun 4th, 2003, 10:36pm »

on Jun 4th, 2003, 2:43pm, benelek wrote:

on a less focussed sidenote, Tony would you happen to be another SydneySider i had a quick look around your site, and noticed the phone number down the bottom, complete with the sydney/NSW area code!

 
Hi Benelek
 
Yep I'm from Sydney,the Southside. I looked around for a java preloader, and there are plenty around...that may be the way to go at present...looking at a blank grey screen dosent appeal to me either if there is a way around it.
 
Tony
 
Pages: 1 

« Previous topic | Next topic »