Writing optimized screeshot utility.

  • Hi all,

    I want to write optimized screenshot utility to make videos from screeen and
    therefore i want to know what parts of the screen have changed since last
    snapshot. I can think of two alternatives:

    1) Is it possible to get dirty region information from window manager via a
    callback or such?
    2) Is it possible to detect 'update' events sent to/from windows?

    I would appreciate any pointers to right direction!

    Thanks,

    Teemu Keinonen
  • On Nov 20, 2007, at 4:02 AM, Teemu Keinonen wrote:

    > Hi all,
    >
    > I want to write optimized screenshot utility to make videos from
    > screeen and
    > therefore i want to know what parts of the screen have changed since
    > last
    > snapshot. I can think of two alternatives:
    >
    > 1) Is it possible to get dirty region information from window
    > manager via a
    > callback or such?

    Yes.

    <http://developer.apple.com/documentation/GraphicsImaging/Reference/Quartz_S
    ervices_Ref/Reference/reference.html#//apple_ref/doc/uid/TP30001070-CH1g-F1
    6970
    >

    -Shawn
  • Thank you for the information. However when i try the following:

    void MyScreenRefreshCallback ( CGRectCount count,  const CGRect * rectArray,
    void * userParameter) {
        int i;
        fprintf(stderr, "%i rects\n", count);
        for (i=0; i < count; i++) {
            fprintf(stdout, "%i %i %i %i\n", rectArray[i].origin.x,
    rectArray[i].origin.y, rectArray[i].size.width, rectArray[i].size.height);
        }
    }

    int main(int argc, char **argv)
    {
        CGRegisterScreenRefreshCallback (MyScreenRefreshCallback, NULL);
        CFAbsoluteTime now = CFAbsoluteTimeGetCurrent ();
            while  ( CFAbsoluteTimeGetCurrent ()-now < 15 )  {
                sleep(1);
            }
        CGUnregisterScreenRefreshCallback (MyScreenRefreshCallback, NULL);
        return 0;
    }

    I get no printout whatsoever although screen does change. Is there some
    initialization that's needed before this works?

    Thanks,

    Teemu Keinonen

    On Nov 20, 2007 5:14 PM, Shawn Erickson <shawnce...> wrote:

    >
    > On Nov 20, 2007, at 4:02 AM, Teemu Keinonen wrote:
    >
    >> Hi all,
    >>
    >> I want to write optimized screenshot utility to make videos from
    >> screeen and
    >> therefore i want to know what parts of the screen have changed since
    >> last
    >> snapshot. I can think of two alternatives:
    >>
    >> 1) Is it possible to get dirty region information from window
    >> manager via a
    >> callback or such?
    >
    > Yes.
    >
    > <
    > http://developer.apple.com/documentation/GraphicsImaging/Reference/Quartz_S
    ervices_Ref/Reference/reference.html#//apple_ref/doc/uid/TP30001070-CH1g-F1
    6970

    >>
    >
    > -Shawn
    >
  • Ok, figured it out myself. I get printouts now:

        [NSApplication sharedApplication];
        CGRegisterScreenRefreshCallback (MyScreenRefreshCallback, NULL);
        [NSApp run];

    ----

    Thank you for the information. However when i try the following:
    void MyScreenRefreshCallback ( CGRectCount count,  const CGRect * rectArray,
    void * userParameter) {
        int i;
        fprintf(stderr, "%i rects\n", count);
        for (i=0; i < count; i++) {
            fprintf(stdout, "%i %i %i %i\n", rectArray[i].origin.x,
    rectArray[i].origin.y, rectArray[i].size.width, rectArray[i].size.height);
        }
    }
    int main(int argc, char **argv)
    {
        CGRegisterScreenRefreshCallback (MyScreenRefreshCallback, NULL);
        CFAbsoluteTime now = CFAbsoluteTimeGetCurrent ();
            while  ( CFAbsoluteTimeGetCurrent ()-now < 15 )  {
                sleep(1);
            }
        CGUnregisterScreenRefreshCallback (MyScreenRefreshCallback, NULL);
        return 0;
    }

    I get no printout whatsoever although screen does change. Is there some
    initialization that's needed before this works?

    Thanks,

    Teemu Keinonen

    On Nov 20, 2007 5:14 PM, Shawn Erickson <shawnce...> wrote:

    >
    > On Nov 20, 2007, at 4:02 AM, Teemu Keinonen wrote:
    >
    >> Hi all,
    >>
    >> I want to write optimized screenshot utility to make videos from
    >> screeen and
    >> therefore i want to know what parts of the screen have changed since
    >> last
    >> snapshot. I can think of two alternatives:
    >>
    >> 1) Is it possible to get dirty region information from window
    >> manager via a
    >> callback or such?
    >
    > Yes.
    >
    > <http://developer.apple.com/documentation/GraphicsImaging/Reference/Quartz_S
    ervices_Ref/Reference/reference.html#//apple_ref/doc/uid/TP30001070-CH1g-F1
    6970
    >  >
    >
    > -Shawn
    >
  • On Nov 21, 2007 6:15 AM, Teemu Keinonen <tkeinonen...> wrote:
    > Ok, figured it out myself. I get printouts now:
    >
    > [NSApplication sharedApplication];
    > CGRegisterScreenRefreshCallback (MyScreenRefreshCallback, NULL);
    > [NSApp run];

    Yeah you need an active connection to the window server and an active
    runloop in the main thread.

    -Shawn
  • Is there any way to make connection to window server and create runloop
    without using

    > [NSApplication sharedApplication];
    > [NSApp run];

    pair? I want to create a library for screenshotting, not a standalone
    application.
    That application icon appearing to dock is very unwanted behaviour.

    - T. Keinonen

    On Nov 21, 2007 6:20 PM, Shawn Erickson <shawnce...> wrote:

    > On Nov 21, 2007 6:15 AM, Teemu Keinonen <tkeinonen...> wrote:
    >> Ok, figured it out myself. I get printouts now:
    >>
    >> [NSApplication sharedApplication];
    >> CGRegisterScreenRefreshCallback (MyScreenRefreshCallback, NULL);
    >> [NSApp run];
    >
    > Yeah you need an active connection to the window server and an active
    > runloop in the main thread.
    >
    > -Shawn
    >
  • On 23 Nov 2007, at 10:52, Teemu Keinonen wrote:

    > Is there any way to make connection to window server and create
    > runloop
    > without using
    >
    >> [NSApplication sharedApplication];
    >> [NSApp run];
    >
    > pair? I want to create a library for screenshotting, not a standalone
    > application.
    > That application icon appearing to dock is very unwanted behaviour.

    Try setting LSUIPresentationMode or LSUIElement, or both.

    Nicko
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today