Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Grab displayed image on CDisplayWindow3D #32

Closed
byohan opened this issue Mar 18, 2014 · 2 comments
Closed

Grab displayed image on CDisplayWindow3D #32

byohan opened this issue Mar 18, 2014 · 2 comments

Comments

@byohan
Copy link

byohan commented Mar 18, 2014

Hello,

First of all I want to thank for your great work on MRPT.
It's a huge help on my project.

I hope it is the right place to ask this question.

I would like to know how to grab the current image displaying on a CDisplayWindow3D.
I tried getLastWindowImage() but although it returns true and an image with the right size, the image is all gray with one white block at the top left ( saved image with CImage::saveToFile )
When i try with getLastWindowImagePtr(), I always obtain a null pointer...
My code is basically :
class myClass :
{
public :
myClass(){
m_3DWnd = new CDisplayWindow3D("Title",1280,1024) ;
m_3DWnd->captureImagesStart();
};

   void main_function
  {
                     for(;;)
                     {
                       /* operations to create newData */                              
                       updateDisplay( newData );
                      }
                      m_3DWnd->captureImagesStop();
  };

  void updateDisplay
  {
       COpenGLScenePtr &scenePtr = m_3DWnd->get3DSceneAndLock();
       COpenGLScenePtr newScene = COpenGLScene::Create();


        /* Add  some stuff to newScene  */

       scenePtr = newScene;
       m_3DWnd->unlockAccess3DScene();
       m_3DWnd->forceRepaint();
  };
   private :
    CDisplayWindow3D* m_3DWnd;

};

What I am doing wrong ?
Thank you in advance

@jlblancoc
Copy link
Member

Hi,

Are you using Windows, right? I have noticed that kind of errors in Windows for a while now but didn't have time to investigate it since in Linux the same wxWidgets functions for screen capture work nice. I think it has to do with Windows hardware graphics acceleration.

I don't have time to do an in depth research on the problem so, please, if you do some research and find a way to disable it to allow capturing in Windows let us know here. It's the same problem that does not allow taking screenshots from a video player, etc.
Or if you find any reference about how to solve the problem from the programmatic point of view (which API to use for screen capture,...) please let me know as well so I can modify MRPT sources accordingly.

Thanks.

@byohan
Copy link
Author

byohan commented Mar 19, 2014

Hi ,

Thanks for your quick answers !
I am actually developing on Windows and you gave me the solution !
By just changing the window thema from aero ( window 7) to classic, the problem has been solved. It seems to be actually related to Windows Hardware Acceleration.
Unfortunately I can't give a programmatic solution ( no time too to go in depth in this problem ).
Hope this temporary solution could help.

Thanks , you saved me a lot of time !

jlblancoc pushed a commit that referenced this issue Aug 27, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants