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_
   Topics & Contributions
   Tools
(Moderator: REAS)
   Example for hi-res offscreen drawing (0068)
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: Example for hi-res offscreen drawing (0068)  (Read 1419 times)
amoeba

WWW
Example for hi-res offscreen drawing (0068)
« on: Dec 2nd, 2004, 2:43pm »

ok, just hacked this up for a workshop. it shows how to draw into a large offscreen buffer and then save it as a file when the user clicks on the screen.
 
based on hints from ben etc, and works fine in 0068.
 
Code:
int cnt;
BGraphics buf;
BImage offscreenImage;
boolean doSave;
 
void setup() {
  size(400,400);
  background(200);
   
  // set up large virtual image
  buf=new BGraphics(3000,3000);
  buf.ellipseMode(CENTER_DIAMETER);
//  buf.smooth();
 
  offscreenImage = new BImage(buf.pixels, buf.width, buf.height, RGB);
  doSave=false;
 
}
 
void loop() {
 
  float rad=random(10,200);
  buf.ellipse(random(buf.width),random(buf.height), rad,rad);
 
  image(offscreenImage, 0, 0);
 
  if(doSave) {
    String filename="BIG_";
    if(cnt<10) filename=filename+"000";
    else if(cnt<100) filename=filename+"00";
    else if(cnt<1000) filename=filename+"0";
 
    println("Saving "+filename+cnt+".tga");
 
    buf.save(filename+cnt+".tga");
    cnt++;
    doSave=false;
  }
}
 
void mousePressed() {
  doSave=true;
}
 

marius watz // amoeba
http://processing.unlekker.net/
Hannes

WWW
Re: Example for hi-res offscreen drawing (0068)
« Reply #1 on: Dec 8th, 2004, 4:33pm »

if you draw the image rescaled to the Applet dimensions you have got a complete preview of the off-screen image ...
 
image(offscreenImage, 0, 0, width, height);
 

Everything is possible ... just try it!
amoeba

WWW
Re: Example for hi-res offscreen drawing (0068)
« Reply #2 on: Dec 10th, 2004, 9:54am »

yep, I put that in about 2 sec after posting it. laziness abounds.
 

marius watz // amoeba
http://processing.unlekker.net/
Pages: 1 

« Previous topic | Next topic »