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 › saving image file with transparency problem
Page Index Toggle Pages: 1
saving image file with transparency problem (Read 539 times)
saving image file with transparency problem
Oct 12th, 2008, 3:49pm
 
hello,

i'm writing a small program to concatenate a group of similar tga images into one column of images and to save the result into a tga file respecting the transparency of sourced tga images in the resulting one.

i've already written program that makes it whithout respect to transparency and now i need some help to upgrade it to the fully functional one.

in reference i've found the PGraphics object that possibly could help me with my problem, but i have no idea how to use it in my case.

this is my code:

int i;
int n = 100;
size(50, n*50);
PImage a;
for(i=1;i<=n;i++) {
a = loadImage("knob"+i+".tga");
image(a, 0, i*50-50);
}
save("knob_concat.tga");
Re: saving image file with transparency problem
Reply #1 - Oct 12th, 2008, 10:29pm
 
save() method's reference says :
Quote:
All images saved from the main drawing window will be opaque. To save images without a background, use createGraphics().


So you'll have to draw your images on a buffer :

Code:
int i;  
int n = 100;
size(50, n*50);
PGraphics pg = createGraphics(width, height, P3D);
PImage a;
for(i=1;i<=n;i++) {
a = loadImage("knob"+i+".tga");
pg.image(a, 0, i*50-50);
}
pg.save("knob_concat.tga");
Re: saving image file with transparency problem
Reply #2 - Oct 13th, 2008, 8:40am
 
i've tried this just now, antiplastik. resulting image is still opaque. only background color is changed from grey to black.
Re: saving image file with transparency problem
Reply #3 - Oct 15th, 2008, 7:05pm
 
Works with JAVA2D instead of P3D:
Code:
PImage bigImage;
int n = 6;
int IMAGE_SIZE = 48;

void setup()
{
PGraphics bigImage = createGraphics(IMAGE_SIZE, IMAGE_SIZE * n, JAVA2D);
bigImage.beginDraw();
for (int i = 0; i < n; i++)
{
PImage tpi = loadImage("E:/temp/testImage" + (i + 1) + ".png");
bigImage.image(tpi, 0, i * IMAGE_SIZE);
}
bigImage.endDraw();
bigImage.save("BigImage.png");
exit();
}
Re: saving image file with transparency problem
Reply #4 - Oct 16th, 2008, 8:17pm
 
this one really works.
thank you, PhiLho. you're the best Smiley
Page Index Toggle Pages: 1