I need to set the render background to white (until then everything is OK with renderer->SetBackground(1.0,1.0,1.0)) and TRANSPARENT (otherwise my image doesn’t appear, it is everything white).
That’s the problem, I can’t manage to have a white transparten background. I am sure this should be an easy question but I didn’t find a solution for that anywhere.
I have written an example for you TransparentBackground.py (3.5 KB) . In this a cube is rendered on a Silver non-transparent background and a cone is rendered on MidnightBlue background. You will see that the background is indeed Silver showing that the layer one background is transparent. The proof is that the cube is visible and the background is Silver. I hope this example shows you what to do.
@lllaa Here are the files: TransparentBackground.zip (4.1 KB) . I have also included an updated Python version here. Sometime, over the next few days, I will add these to the VTKExamples site where you will find them in the Rendering section.
It is now in the VTKExamples master. Unfortunately at this stage it will not appear on the web pages. If you ckeck out VTKExamples, look for src/Python/Rendering/TransparentBackground.py and src/Cxx/Rendering/TransparentBackground.cxx.
Dear Andrew Maclean,
thank for your help.May I ask you another question?
I used QvtkWidget in QT designer.
But the QvtkWidget had a black background when I created it on the “MainWindow”.It makes my photo has a black background.
I want to make the black background diappeared.But I failed to find the way from your code.
I put the pics below.
Wish for your reply.