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 & HelpSyntax Questions › Image Blending and transparency
Page Index Toggle Pages: 1
Image Blending and transparency (Read 615 times)
Image Blending and transparency
Jun 5th, 2008, 9:00pm
 
Hi all,

I am writing a little application for doing multiple exposure photography. the app will record a number of images, and then blend them together into a composite image.

I have implemented this in 2 different ways.

1.each image will be transparent (using tint)
(alpha = 255/numOfImages)

or

2.using blend to combine the images.
( blend(imageBank[i], 0, 0, 800, 600, 0, 0, 800, 600,             blendM);


I would like to combine the two, in other words to draw a transparent images with a blend applied to it. Is this possible? using tint(255,someAlpha) seems to have no effect.
any ideas or suggestions?
Re: Image Blending and transparency
Reply #1 - Jun 5th, 2008, 11:12pm
 
It would be nice if tint() could be applied to a PImage, but it seems to work only on a PGraphics.
A solution I found is to simulate the tint (actually, just the add transparency part) manually:
Code:
final String PATH = "D:/_PhiLhoDocs/Images/";
final int IMAGE_NB = 5;
final color TINT = 255 / IMAGE_NB;

void setup()
{
noLoop();
PImage pi = loadImage(PATH + "HPIM1592.JPG");
AddTransparency(pi, TINT);
// Dimension to image size
size(pi.width, pi.height);
// Display whole image
image(pi, 0, 0);

pi = loadImage(PATH + "HPIM1593.JPG");
AddTransparency(pi, TINT);
blend(pi, 0, 0, pi.width, pi.height, 0, 0, pi.width, pi.height, LIGHTEST);

pi = loadImage(PATH + "HPIM1595.JPG");
AddTransparency(pi, TINT);
blend(pi, 0, 0, pi.width, pi.height, 0, 0, pi.width, pi.height, LIGHTEST);

pi = loadImage(PATH + "HPIM1597.JPG");
//AddTransparency(pi, TINT);
blend(pi, 0, 0, pi.width, pi.height, 0, 0, pi.width, pi.height, LIGHTEST);

pi = loadImage(PATH + "HPIM1598.JPG");
AddTransparency(pi, TINT);
blend(pi, 0, 0, pi.width, pi.height, 0, 0, pi.width, pi.height, LIGHTEST);
}

void AddTransparency(PImage pi, int transparency)
{
transparency <<= 24;
for (int i = 0; i < pi.width; i++)
{
for (int j = 0; j < pi.height; j++)
{
color c = pi.pixels[i + j * pi.width];
c = c & 0x00FFFFFF | transparency;
pi.pixels[i + j * pi.width] = c;
}
}
}
Re: Image Blending and transparency
Reply #2 - Jun 6th, 2008, 8:31pm
 
thanks PhiLho. that seems to do exactly what I need.
Page Index Toggle Pages: 1