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)
   image backgrounds
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: image backgrounds  (Read 1017 times)
benelek

35160983516098 WWW Email
image backgrounds
« on: Jan 15th, 2003, 1:01am »

i don't suppose it's possible to have an image as the background?
 
ie, background(theImage);
 
it's all good and fun drawing images to specific points in a 3d space, but can i draw the image at the size of the applet, and behind everything else (without the bother of resizing and repositioning it whenever i move something backwards)?
« Last Edit: Jan 15th, 2003, 1:04am by benelek »  
benelek

35160983516098 WWW Email
Re: image backgrounds
« Reply #1 on: Jan 15th, 2003, 2:44am »

hehe, oooh i think i found an answer to this one myself (as soon as the color array thing is fixed). check out the following in the meantime:
 
Code:

 
void setup() {
  size(228,240);
  background(255);
  moo=loadImage("moo.gif");
  mooPixGreen = new int[pixels.length];
}
 
BImage moo;
int[] mooPixGreen;
boolean firstTime=true;
 
void loop() {
  if(firstTime) {
    image(moo,0,0);
    for(int i=0; i<pixels.length; i++) {
      mooPixGreen[i]=int(green(pixels[i]));
    }
    firstTime=false;
  }
  System.arraycopy(mooPixGreen,0,pixels,0,mooPixGreen.length);
 
  // put ur other stuff here.
}
 

 
of course, u have to have the image in the data directory... and, because i'm using an int array to store the image (instead of a color array), u can only use one channel at a time. but it's cool anyway
 
-jacob
 
fry


WWW
Re: image backgrounds
« Reply #2 on: Jan 15th, 2003, 2:49am »

use noBackground() inside setup.. then at the beginning of your loop(), include this:
 
System.arraycopy(mooPixGreen.pixels, 0, pixels, 0, pixels.length);
 
your image should be the same as what you setup with for size()
 
background(some_image) will be added in the future.
 
benelek

35160983516098 WWW Email
Re: image backgrounds
« Reply #3 on: Jan 15th, 2003, 2:51am »

mm, yes a somewhat shorter method
 
benelek

35160983516098 WWW Email
Re: image backgrounds
« Reply #4 on: Jan 15th, 2003, 2:56am »

actually, i didn't realise p5 could store whole colours in int format.
 
using "mooPixBlue[i]=pixels[i];" instead of "mooPixBlue[i]=int(blue(pixels[i]));" will store all the colour information for that pixel, not just a certain chanel.
 
REAS


WWW
Re: image backgrounds
« Reply #5 on: Jan 15th, 2003, 5:23pm »

For clarity:
 
Code:

BImage bg;
 
void setup()  
{
  size(200,200);
  noBackground();
  bg = loadImage("sky.jpg");
}
 
void loop()  
{
  // Loads image into the background very quickly
  System.arraycopy(bg.pixels, 0, pixels, 0, width*height);
}
« Last Edit: Jan 15th, 2003, 5:23pm by REAS »  
fry


WWW
Re: image backgrounds
« Reply #6 on: Jan 15th, 2003, 7:34pm »

on Jan 15th, 2003, 2:56am, benelek wrote:
actually, i didn't realise p5 could store whole colours in int format.

 
yeah, an explanation is here:
http://proce55ing.net/discourse/yabb/board_Syntax_action_displa_y_num_1037826044.html
 
 
benelek

35160983516098 WWW Email
Re: image backgrounds
« Reply #7 on: Jan 16th, 2003, 4:43am »

on Jan 15th, 2003, 5:23pm, REAS wrote:
Code:

 
  System.arraycopy(bg.pixels, 0, pixels, 0, width*height);
 

 
hmm... any date set for updating the reference section object properties like "img.pixels" are like invisible gifts being unveiled one by one
 
-jacob
« Last Edit: Jan 16th, 2003, 4:43am by benelek »  
REAS


WWW
Re: image backgrounds
« Reply #8 on: Jan 20th, 2003, 10:36am »

I think many invisible gifts will remain invisible, but some like this will be documented. We're trying to keep the docs as small as possible.
 
Pages: 1 

« Previous topic | Next topic »