I was wondering if anyone might have a pointer to some cross-pllatform (Windows, macOS) lightweight API or other code to perform a screen capture.
Without going in too much details I am looking to develop a plugin where it might come handy to take a screen shot. Not only of the 3D viewport (as this could be achieved via the BaseDraw and its EditorWindow.), but preferably the entire desktop.
I have looked at a possible solution using GDI, but this is Windows only. And not being an expert in macOS development I have no idea regarding available graphic frameworks (cocoa, metal, ?)
Any help would be appreciated.
Thanks in advance,
I noticed there is a void* GetEditorWindow(void) available in c4d_bitmapfilter.h which according to this post in the legacy forum could be casted to an HWND. This might be helpful to get me started with Win32 GDI, but no idea for macOS.
Got it working on Windows with Win32 GDI. That will allow me to further prototype the plugin. I will see how to proceed on macOS when I am ready to port the plugin over. Maybe by using CGWindowListCreateImage.
In the meantime I am still open for suggestions about a cross-platform solution.
I am not familiar with any C++ screen-grab libraries, so I cannot say much.
Thanks for the suggestions.
I did indeed have a look at some implementations available on GitHub. But the few I looked at were just to large a project to find the proverbial needle in the haystack. Didn't want to waste my time going through all the code. Hence I went on to build my prototype implementation using Win32 GDI.
And I did indeed encounter some references to PIL and pillow while seeing if using Python provided alternative solutions. However, I have no experience with Python modules and their installation on customer's system. As such, I will probably stay clear from Python and the need for 3rd party modules.
Hi @C4DS, just to confirm that there is nothing built-in Cinema 4D.
For python most of the library in the end only reroutes through OS call and does have a system dependant call, so you will probably end with something like that also in C++.