Screenshot without background

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
raveneyex
Posts: 19
Joined: Thu Jul 15, 2010 8:16 am
Contact:

Screenshot without background

Post 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!!!
raveneyex
Posts: 19
Joined: Thu Jul 15, 2010 8:16 am
Contact:

Screenshot without background or GUI

Post 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?
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post 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.
raveneyex
Posts: 19
Joined: Thu Jul 15, 2010 8:16 am
Contact:

Post 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
greenya
Posts: 1012
Joined: Sun Jan 21, 2007 1:46 pm
Location: Ukraine
Contact:

Post 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:
raveneyex
Posts: 19
Joined: Thu Jul 15, 2010 8:16 am
Contact:

Post 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!!!!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
raveneyex
Posts: 19
Joined: Thu Jul 15, 2010 8:16 am
Contact:

Post 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!
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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.
raveneyex
Posts: 19
Joined: Thu Jul 15, 2010 8:16 am
Contact:

Post 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)
Post Reply