Can't screenshot plugin UIs

createComponentSnapshot gives a completely white (for AUs) or completely black (for VSTs) image when the component is the editor of a plugin (e.g. a VSTPluginWindow). Why can they be drawn to the screen but not to an image, and does anyone know a way around this?

this is on macOS, btw. Maybe it has to do with security, you can’t access the pixels that you don’t “own”?

It’s a bit tricker as the windows aren’t JUCE component, they’re native windows. You need to use createSnapshotOfNativeWindow and pass it the native window handle (ComponentPeer::getNativeHandle()).

You’ll have to account for any window borders or scaling yourself and that depends on the platform.

5 Likes

Thanks dave! However createSnapshotOfNativeWindow doesn’t seem to be exposed? How can I call it without hacking into the JUCE source code (which I’d rather not do for obvious reasons)?

Just forward declare it:

namespace juce
{
    Image createSnapshotOfNativeWindow (void* nativeWindowHandle);
}
1 Like

aaaahhh thanks… I tried that but I forgot the namespace. It works, cheers!

1 Like

For me, createSnapshotOfNativeWindow() is working fine on Windows, but the same code on Mac OS gives me snapshot of a parent window. Any idea??