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 & HelpOther Libraries › Save SVG as PNG without Background
Page Index Toggle Pages: 1
Save SVG as PNG without Background (Read 1606 times)
Save SVG as PNG without Background
Dec 21st, 2009, 5:20am
 
Hej everybody,

I'm wondering about whether its possible to draw a loaded SVG with Geomerative and save the generated screen as a *.png file without background? Does anybody has an idea?

Thanks, fejngold
Re: Save SVG as PNG without Background
Reply #1 - Dec 21st, 2009, 5:35am
 
you can take a look at this threat
http://processing.org/discourse/yabb2/?num=1231879947
Re: Save SVG as PNG without Background
Reply #2 - Dec 21st, 2009, 6:40am
 
Thank you for the fast reply. I discovered this thread before, but the shown solution didn't work for me with Geomerative library.

I tried something like this:

Code:

frameToSave = createGraphics(width, height, JAVA2D);
frameToSave.beginDraw();
frameToSave.noFill();
svg.draw();               //Draws my Geomerative RShape
frameToSave.endDraw();
frameToSave.save("Image.png");


This was my pretty green approach which of course didn't work and created a transparent image without my drawn SVG.

Re: Save SVG as PNG without Background
Reply #3 - Dec 21st, 2009, 7:07am
 
Okay, I was off the track.

As it seems I don't need to create a PGraphic in view of the fact that the Geomerative has one. It's named "g".

Unfortunately I'm still having the problem of the transparent background.

Doing

Code:

        g.noFill();
        svg.draw();
        g.save("test.png");


returns at least a PNG containing the SVG paths ,but still with a kind of grey background.

Re: Save SVG as PNG without Background
Reply #4 - Dec 21st, 2009, 8:16am
 
JavaDoc of Geomerative is a bit terse... Smiley
But well, I see in RShape page:
Quote:
void draw(processing.core.PApplet p)
void draw(processing.core.PGraphics g)

You use... well, neither!
You should use:
Code:
frameToSave.beginDraw();
frameToSave.noFill();
svg.draw(frameToSave); //Draws my Geomerative RShape
frameToSave.endDraw();

You have to tell Geomerative it has to use your own graphics to do its job, it cannot guess which one to use.
Re: Save SVG as PNG without Background
Reply #5 - Dec 21st, 2009, 8:44am
 
Thanks a lot. This works fine. Great!!!
Page Index Toggle Pages: 1