Loading...
Logo
Processing Forum
Hello everybody,
I'd like to be able to have a transition between two images. I'm using masks at the moment, but is there a better way? Id like to Load the pixels with the alpha channel ... but I dont know how to set the alpha parameter.. what the range of values?

thanks

Replies(3)

Hi,

You can set the alpha of a pixel like that (not checked) :

Copy code
  1. PImage img = loadImage (...);

Copy code
  1. img.loadPixels();
  2. changeAlpha(img,x,y,your_alpha);
  3. img.updatePixels();

Copy code
  1. //change alpha of the pixel x,y
  2. void changeAlpha(PImage img, int x, int y, int a) {
  3. int id =  x+y*img.width;
  4. int val = img.pixels[id];
  5. img.pixels[id] = (val & 0xFFFFFF) | (a<<24);
  6. }
hm ok I'll try and come back
Check out the tint() method:  http://processing.org/reference/tint_.html You can set the RGBA value of an image using this.