Can't screenshot plugin UIs


#1

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?


#2

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


#3

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.


#4

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)?


#5

Just forward declare it:

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

#6

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