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)
   BImage 8bit greyscale
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: BImage 8bit greyscale  (Read 780 times)
Sjeiti

WWW
BImage 8bit greyscale
« on: Mar 14th, 2005, 8:35pm »

BImage 8bit greyscale... is that possible?
 
The reason I'm asking is because when rendering an animation at 800/600 I can only buffer about 50 frames before I get memory problems. Then I switched to 400/300 at 200 frames. I figured since BImage is 32bit, an 8bit buffer would get even more frames.
What would be even better is some sort of jpeg, gif or video compression.
(of course I can always save frames in authoring mode but I want it to work online as well)
 

http://www.sjeiti.com/
toxi

WWW
Re: BImage 8bit greyscale
« Reply #1 on: Mar 14th, 2005, 10:28pm »

you'd have to use a byte[] array for each image instead of a standard int[] pixelbuffer as used by BImage. every frame you'd then have to transfer the values from the byte arrays to the "pixels" array of the BImage, making sure you also set all colour channels:
 
Code:

// byte buffer for greyscale data
byte[] buffer=new byte[400*300];
 
void buildImageGS(byte[] buf, BImage img) {
  int[] pix=img.pixels;
  for(int i=0; i<buf.length; i++) {
    byte b=buf[i];
    int c=(int)(b<0 ? 256+b : b);
    pix[i]=0xff000000|c<<16|c<<8|c;
  }
}

 

http://toxi.co.uk/
Sjeiti

WWW
Re: BImage 8bit greyscale
« Reply #2 on: Mar 15th, 2005, 11:03am »

it took me a while to figure out how to convert an int to a byte  ( (byte)x ) ... but it works like a charm now
thanks
 

http://www.sjeiti.com/
Pages: 1 

« Previous topic | Next topic »