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 › createGraphic Transparent background
Page Index Toggle Pages: 1
createGraphic Transparent background (Read 857 times)
createGraphic Transparent background
Mar 25th, 2010, 5:56am
 
I've searched through the forum and have tried different ways of getting this to work with no success. What I'd like to do is draw a png onto a transparent PGraphics buffer and then display it on the screen.
I can make the background transparent or translucent if nothing is written to it with background(x,y,z,alpha), but when I try to draw a png to it it becomes opaque.

I have an example at Stever dot cc. Click on
Processing Transparent Background
at the top of the page

If anyone can give me a hand with this I'd be eternally grateful.

Here's the code:

PImage bg,alfred;
PGraphics pg2;

 
  void setup()
{
 bg = loadImage("slide1_large.jpg");
 alfred = loadImage("alfred.png");
 size(599,629, P3D);
 background(bg);
}

PGraphics getBuffer(PImage img){
  PGraphics pg1= createGraphics(300,300, P3D);
 
  pg1.beginDraw();
   pg1.background(50,50,10,5);
  pg1.image(img,0,0);
  pg1.endDraw();
  return pg1;
}


void draw(){
pg2=getBuffer(alfred);
image(pg2,0,0);   // Buffered Image
image(alfred,300,0);  // Image blit directly to screen
}



Steve
Re: createGraphic Transparent background
Reply #1 - Mar 25th, 2010, 8:45am
 
Last time I checked, background transparency of PGraphics worked only in JAVA2D mode.
Re: createGraphic Transparent background
Reply #2 - Mar 25th, 2010, 9:16am
 
Yes!!!!!!!!!!!!!!!!!!
Thank You!!!!!!!!!!
Very very much
Re: createGraphic Transparent background
Reply #3 - Mar 25th, 2010, 9:47am
 
Big questions:

what happens if you have a partially transparent PImage pixel and you use image() to copy a (partially) transparent image from a PNG... do you get a partially transparent result, or a fully opaque result with a blended colour?

I'm sure other tricky variations arise.

-spxl
Page Index Toggle Pages: 1