Page 1 of 1

Screenshot without background

Posted: Tue Sep 21, 2010 9:05 am
by raveneyex
Hey Everyone!

I have a big question regardings screenshots and I can't seem to be able to find any related post in here (if there is one, then by all means please point it to me).

The situation that I have is the next:

I have a rendered scene on screen (just a bunch of models loaded onto a parent model. i.e. A dummy with clothes).
I haven't loaded any background or skybox or anything.
I need to save that scene to an image file but without the background.

The "createScreenShot()" function on IVideoDriver takes the (lack of)background and paint it black/grayish and it also renders the buttons and all the GUI of my app (as expected in a screenshot)

So, my question: is there a way to render to image JUST the scene nodes and not the whole window?
Thanks for your help!!!

Screenshot without background or GUI

Posted: Tue Sep 21, 2010 9:11 am
by raveneyex
Here's the screenshot produced by the createScreenShot method on the IVideoDriver.

Image

Notice how the screenshot captures the buttons and all gui elements, plus the background?
Is there a way to ONLY GET the model?

Posted: Tue Sep 21, 2010 10:00 am
by greenya
When you need to make a screenshot, you better do your own 1 render loop without gui, like next:

Code: Select all

device->run();
driver->beginScene();
smgr->drawAll();
driver->endScene();

driver->createScreenShot (...
this will make you screenshot without gui.

P.S.: I don't know how to remove background.

Posted: Tue Sep 21, 2010 10:28 am
by raveneyex
Hey greenya!

Thanks for your help, but I didn't quite understand what you told me.

You're telling me that I have to create one run of the render loop where I don't display the GUI and then take the screenshot?

Thanks :D

Posted: Tue Sep 21, 2010 10:39 am
by greenya
raveneyex wrote: Thanks for your help, but I didn't quite understand what you told me.

You're telling me that I have to create one run of the render loop where I don't display the GUI and then take the screenshot?
Actually yes.
In the place where you call createScreenShot(), just insert my code above, you screenshot will be generated without GUI on it. :roll:

Posted: Tue Sep 21, 2010 10:44 am
by raveneyex
YES!!! THANK YOU!!

You're the best!
It worked :D :D

As for the background I changed it to white and I think it better suits my needs for now...

THANKS AGAIN!!!!

Posted: Tue Sep 21, 2010 10:53 am
by hybrid
If you need to keep the image within Irrlicht, you should take a look at RenderToTexture, which does almost the same, but returns a texture instead of an image. Moreover, this has no problems with overlays or hidden parts of the window, where screenshots usually fail.

Posted: Tue Sep 21, 2010 11:02 am
by raveneyex
@Hybrid

Actually I was looking for that method (renderTargetToTexture) since I've seen some people mencioning it on the forum, but couldn't find a code snippet where it shows usage, and I've tried and failed epicly by my own.

However, I do need the image outside Irrlicht in two ways:
1. An image file (already done)
2. On the clipboard.

Do you know a way to access the image data so I can pass it to the clipboard?

Thanks mate!

Posted: Tue Sep 21, 2010 11:44 am
by hybrid
Clipboard is highly platform dependent. For text copying, we have integrated some support into the OSOperator. But images are not supported by Irrlicht. You have to use whatever your OS provides for you.

Posted: Tue Oct 05, 2010 10:01 am
by raveneyex
Just for the sake of completion for this thread.

I haven't managed to find a way to create the Screenshot without the background, so I turned it white wich is more "image-like" and suits my needs better.

As for copying said screenshot to the clipboard, here's a link to the sources I used for that.
WARNING: Window$ Only.

Code: Select all

http://www.codeproject.com/KB/clipboard/dib2clipboard.aspx
(It's funking hell to work with Windows Clipboard)