Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Cross platform screencapture code

    General Talk
    3
    5
    764
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C4DSC
      C4DS
      last edited by C4DS

      Hi,
      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,
      Daniel

      EDIT:
      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.

      1 Reply Last reply Reply Quote 0
      • C4DSC
        C4DS
        last edited by

        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.

        1 Reply Last reply Reply Quote 0
        • ferdinandF
          ferdinand
          last edited by

          Hi,

          I am not familiar with any C++ screen-grab libraries, so I cannot say much.

          • I assume you are aware of the fact that there are multiple C++ implementations on GitHub. While I also would be hesitant to rely on some random github repository, taking a peak into what they are doing on the Mac side of things would not hurt.
          • This probably does not satisfy your criteria of lightweight, but you could use the Python module PIL or its sort of successor pillow. Both are very mature and have a screenshot functionality and are multi-platform. Although the screen-grab stuff does not work on Linux.

          Cheers,
          zipit

          MAXON SDK Specialist
          developers.maxon.net

          C4DSC 1 Reply Last reply Reply Quote 2
          • C4DSC
            C4DS @ferdinand
            last edited by

            @zipit
            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.

            1 Reply Last reply Reply Quote 0
            • M
              m_adam
              last edited by

              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++.

              Cheers,
              Maxime.

              MAXON SDK Specialist

              Development Blog, MAXON Registered Developer

              1 Reply Last reply Reply Quote 0
              • First post
                Last post