Hi Sandra,
On Fri, 2004-08-27 at 13:43, Sandra Helsper wrote:
> Hi
>
> I have a problem with grabbing an scene an write it in an image. I have
> a derived class from QMainWindow and in its constuctor I create a
> SimpleSceneManager and a OSGQGLManagedWidget. The I create a node and
> add it to the ManagedWidget.
> SimpleSceneManager has a MouseReleaseEvent in which I try to grabb the
> scene and write it in an image.
> So but all I resolve is an one-pixel-sized black image.
> This is the excerpt where I write the image. It is a method from
> A3D_SceneManager which is derived from SimpleSceneManager.
>
> OSG::ImagePtr image;
> image= OSG::Image::create();
> beginEditCP(image);
> image->setWidth(800);
> image->setHeight(600);
> image->set(Image::OSG_RGB_PF, 1);
This call will set the resolution to 1,1 again. That's not a problem
(see below), it's just a little strange.
> //image->set(Image::OSG_RGB_PF, resX, resY);
> endEditCP(image);
>
> OSG::WindowPtr win = getWindow();
> OSG::ViewportPtr vp = win->getPort(0);
>
> GrabForegroundPtr fgnd;
> vp->getForegrounds().clear(); // fraglich?
No, that's called by the Viewport, it shouldn't be called by the user
explicitly.
> fgnd = GrabForeground::create();
>
> beginEditCP(fgnd);
> fgnd->setImage(image);
> endEditCP(fgnd);
>
> beginEditCP(vp);
> vp->getForegrounds().push_back(fgnd);
> endEditCP(vp);
>
> std::string image_filename = "test.jpg";
>
> image->write(image_filename.c_str());
>
> The whole workspace is available as zip-download
> http://www.graphix.de/osgexample/image.zip
>
> Is there something I didn't make correctly? Or has anyone an idea how to
> make it in a different way?
Ok, the way I expected the GrabFG to be used is like this:
You just it to your at initialization time, and turn it off
(setActive(false);). In this state it won't do anything.
As soon as you want to grab a picture you turn it on, and it will start
grabbing the Viewport into the Image you gave. If the Image is 1x1, it
will automatically be resized to fit the viewport. To actually get a
grab you have to trigger a redraw. After the redraw, the latest image
will be in the Image and you can save it.
If you want to save it to a file anyway, you can also use a
FileGrabForeground, which does exactly that. It can also automatically
increment a counter to save animations, if that's what you want to do.
Hope it helps
Dirk
-------------------------------------------------------
This SF.Net email is sponsored by BEA Weblogic Workshop
FREE Java Enterprise J2EE developer tools!
Get your free copy of BEA WebLogic Workshop 8.1 today.
http://ads.osdn.com/?ad_id=5047&alloc_id=10808&op=click
_______________________________________________
Opensg-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/opensg-users