Hi,
in UGameViewportClient::ProcessScreenShots when bHdrEnabled is true Bitmap array is never filled (capture code uses BitmapHDR) so ScreenshotCapturedDelegate is never called in the snippet below:
if (bScreenshotSuccessful)
{
if (Bitmap.Num() > 0) // this is always Empty in HDR)
{
if (ScreenshotCapturedDelegate.IsBound() && CVarScreenshotDelegate.GetValueOnGameThread())
{
// Ensure that all pixels' alpha is set to 255
for (auto& Color : Bitmap)
{
Color.A = 255;
}
// If delegate subscribed, fire it instead of writing out a file to disk
ScreenshotCapturedDelegate.Broadcast(Size.X, Size.Y, Bitmap);
}
else
{
bIsScreenshotSaved = ProcessScreenshotData(Bitmap, Size, 255, bHdrEnabled, bIsUI, TEXT(".png"));
}
}
else
{
bIsScreenshotSaved = ProcessScreenshotData(BitmapHDR, Size, 1.0f, bHdrEnabled, bIsUI, TEXT(".exr"));
}
}
Project cannot use ScreenshotCapturedDelegate to capture both LDR and HDR input.
Possible quick fix
if (bScreenshotSuccessful)
{
//@CYA EDIT convert HDR to Bitmap in order to get ScreenshotCapturedDelegate triggered in the if below
if (Bitmap.IsEmpty() && !BitmapHDR.IsEmpty() && ScreenshotCapturedDelegate.IsBound() && CVarScreenshotDelegate.GetValueOnGameThread())
{
Bitmap.Reserve(BitmapHDR.Num());
for (FLinearColor& Color : BitmapHDR)
{
Bitmap.Add(Color.ToFColor(true));
}
}
//@CYA END
if (Bitmap.Num() > 0)
{
...
Regards
Cø
Steps to Reproduce
On a C++ project add and call the code below.
When using LDR the ensure always triggers
When screen is HDR callback is never called.
UGameViewportClient::OnScreenshotCaptured().AddLambda([](int32 InSizeX, int32 InSizeY, const TArray<FColor>& InImageData)
{
ensureAlways(false);
});
FScreenshotRequest::RequestScreenshot(false);
Hi Colas,
Thank you for making the effort to create a fix for the screenshot utility. Would it be possible for you to submit this change via a pull request on GitHub? Through pull requests, we can easily review and integrate your changes. Here is a guide on how to create a pull request, in case you have not gone through the process before: https://dev.epicgames.com/documentation/en\-us/unreal\-engine/contributing\-to\-the\-unreal\-engine. Please let me know if you have any further questions.
Hi Tim,
thanks for the quick answer, i’m accessing sources with Perforce (and we’re 2 weeks away from certification, you can read “we’re in the panic path”) that’s why i went for a brute-force quick-fix and not a clean PR request.
I don’t think my proposed code is clean enough for integration “as-it” it’s kind of bypassing the logic for my precise issue, i mostly posted here so other UE user don’t struggle on this like i did 
Cø
Hi Colas,
Thank you for the clarification and the effort to provide a usable workaround. I attempted to review that part of our codebase yesterday to find a more elegant solution, but I concluded that a more knowledgeable developer should examine it instead. I filed a Jira to track that effort here: https://issues.unrealengine.com/issue/UE-354875. Once the link goes live, you should be able to see the status of the ticket. Please let me know if there is anything else I can do for you.
Cheers,
Tim
Ok, sounds good! Have a good rest of your day.
Hi Tim,
thanks for forwarding this to the main dev team, you can close this ticket as it was mainly there for futur updates as it’s hotfixed in our master candidate 
Regards
Cø