Getting a bitmap of viewport in the context of a UE plugin

Hi! I’m developing a UE plugin, and I’m trying to get a bitmap of the main viewport (the one I see on screen when hitting “play” in the editor).
I’ve tried using GEngine->GameViewport, but the end result is an empty bitmap with a screwed-up size. the UGameViewportClient reference is valid though, so at least I got a reference to an actual object back.
I’ve also tried UWorld::GetGameViewport, with a valid UWorld context (works when attempting different things, like passing it to FindObject), but it just returns nullptr…
I know that I can achieve this if I attempt writing this code in an actor context instead, but I’d really prefer if I can just do it in a plugin context that just gets the viewport which is rendered to the screen and nothing else.
Much thanks!