Loading ...
Sorry, an error occurred while loading the content.

X11 screenshot

Expand Messages
  • san.vungoc
    Hi list what would be the easiest way to obtain a screenshot of an arbitrary X11 window (in linux) from an ocaml program ? I m sure several libraries can do
    Message 1 of 5 , Apr 21, 2009
    • 0 Attachment
      Hi list

      what would be the easiest way to obtain a screenshot of an arbitrary X11 window (in linux) from an ocaml program ?

      I'm sure several libraries can do this, but are there any of them that already have bindings for ocaml ?

      Thanks
      San
    • Florent Monnier
      ... I always use xwd which is an utility which comes with the X distribution xwd -root | convert xwd:- /tmp/screenshot.png or xwd -frame | convert xwd:-
      Message 2 of 5 , Apr 26, 2009
      • 0 Attachment
        san.vungoc a écrit :
        > Hi list
        >
        > what would be the easiest way to obtain a screenshot of an arbitrary X11
        > window (in linux) from an ocaml program ?
        >
        > I'm sure several libraries can do this, but are there any of them that
        > already have bindings for ocaml ?


        I always use xwd which is an utility which comes with the X distribution
        xwd -root | convert xwd:- /tmp/screenshot.png
        or
        xwd -frame | convert xwd:- /tmp/screenshot.png

        and "convert" is an utility from the ImageMagick set.

        but if you wish to do this from a program, maybe you could have a look at the
        source code of xwd :
        http://xorg.freedesktop.org/archive/X11R7.4/src/everything/xwd-1.0.2.tar.gz
        and use an Xlib binding to reproduce the same process:
        http://www.linux-nantes.org/%7Efmonnier/OCaml/Xlib/

        dunno if this helps, maybe there are higher level equivalent things in GTK and
        its OCaml bindings
      • san.vungoc
        Thanks a lot. It works very well, except maybe that convert seems to be a bit slow. (What I had in mind is to monitor changes in an X window, like motion
        Message 3 of 5 , Apr 27, 2009
        • 0 Attachment
          Thanks a lot. It works very well, except maybe that 'convert' seems to be a bit slow. (What I had in mind is to monitor changes in an X window, like 'motion' does for a webcam.)
        • Richard Jones
          ... Note that convert is just used to transform the output of xwd into a more common format. You can look at the output of xwd directly - it s in the rarely
          Message 4 of 5 , Apr 27, 2009
          • 0 Attachment
            On Mon, Apr 27, 2009 at 12:44:31PM -0000, san.vungoc wrote:
            > Thanks a lot. It works very well, except maybe that 'convert' seems
            > to be a bit slow.

            Note that 'convert' is just used to transform the output of xwd into a
            more common format. You can look at the output of xwd directly - it's
            in the rarely used xwd format.
            https://secure.wikimedia.org/wikipedia/en/wiki/Xwd

            > (What I had in mind is to monitor changes in an X
            > window, like 'motion' does for a webcam.)

            This is more of an X problem than an OCaml thing. Grabbing
            screendumps periodically is never going to be efficient given the way
            that X works. The uncompressed bitmap of the window needs to be sent
            from the X server back to your client each time. If you want to
            monitor changes to a particular window, perhaps you are better
            injecting your program between the X server and the client you are
            monitoring? Anyway, this is a question for X protocol gurus on one of
            the X mailing lists such as xorg:

            http://lists.freedesktop.org/mailman/listinfo
            http://lists.freedesktop.org/mailman/listinfo/xorg

            Rich.

            --
            Richard Jones
            Red Hat
          • Graham Fawcett
            ... This is off-topic for ocaml-beginners, but another possibility is to use VNC or a similar system to monitor screen state. VNC takes care of the X-specific
            Message 5 of 5 , Apr 27, 2009
            • 0 Attachment
              On Mon, Apr 27, 2009 at 8:55 AM, Richard Jones <rich@...> wrote:
              >
              >
              > On Mon, Apr 27, 2009 at 12:44:31PM -0000, san.vungoc wrote:
              >> Thanks a lot. It works very well, except maybe that 'convert' seems
              >> to be a bit slow.
              >
              > Note that 'convert' is just used to transform the output of xwd into a
              > more common format. You can look at the output of xwd directly - it's
              > in the rarely used xwd format.
              > https://secure.wikimedia.org/wikipedia/en/wiki/Xwd
              >
              >> (What I had in mind is to monitor changes in an X
              >> window, like 'motion' does for a webcam.)
              >
              > This is more of an X problem than an OCaml thing. Grabbing
              > screendumps periodically is never going to be efficient given the way
              > that X works. The uncompressed bitmap of the window needs to be sent
              > from the X server back to your client each time. If you want to
              > monitor changes to a particular window, perhaps you are better
              > injecting your program between the X server and the client you are
              > monitoring? Anyway, this is a question for X protocol gurus on one of
              > the X mailing lists such as xorg:

              This is off-topic for ocaml-beginners, but another possibility is to
              use VNC or a similar system to monitor screen state. VNC takes care of
              the X-specific stuff, and is smart about sending partial
              screen-updates when the majority of the display is unchanged, and so
              is relatively fast. Consider "vnc2swf" for example, which can be used
              to record a screen display into a Shockwave file. VNC also has the
              benefit of being platform-independent, since VNC servers are available
              for all major platforms.

              Best,
              Graham
            Your message has been successfully submitted and would be delivered to recipients shortly.