We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpPrograms › PImage and get method strange
Page Index Toggle Pages: 1
PImage and get method strange? (Read 784 times)
PImage and get method strange?
Jan 11th, 2006, 10:37pm
 
Hello!

Consider this code:
 PImage img = loadImage("ron.jpg");
 img.set(0,0,color(0,0));
 print(alpha(img.get(0,0)));  // returns 255

 image(img,0,0);
 set(0,0,trans);
 print(alpha(get(0,0))); // returns 0

If I understand correctly, the alpha channel is setable only when the image is outputted? I don't see any other logical explanation. This is a real pain because I have a video and a picture with green background and I want to make the image transparent inside the video. That would be no problem at all, but without being able to set the alpha channel it makes it more complicated.
Thanks in advance.
Re: PImage and get method strange?
Reply #1 - Jan 12th, 2006, 12:21am
 
alpha(get(0, 0)) should return 255 as well, so that's a bug, but it's not important for your issue.

img.get() returns 255 because the jpg image is RGB (not ARGB) format. get() should be returning 255 as well, because the main drawing surface cannot be transparent. if you want to work with an image that has a green background, do it entirely within the PImage. if you set the format of the PImage to be ARGB (or open an image that has an alpha channel to begin with), it will properly handle alpha.
Re: PImage and get method strange?
Reply #2 - Jan 12th, 2006, 6:15am
 
Thanks. How about having 2 videos, how would I make one transparent?
Re: PImage and get method strange?
Reply #3 - Jan 12th, 2006, 12:10pm
 
Make a temporary image which you set each frame with myVideo.get(), then make a function which sets an image to a transparency..

OR you could use the fade by st33d
Code:

background(myVideoOne);
tint(255,255,255,(255.0/width)*mouseX);
image(myVideoTwo,0,0);


-seltar
Page Index Toggle Pages: 1