Hi!
I implemented a way to take screenshots at runtime with the Console Execute Command “HighResShot”.
This works by overriding the ProcessScreenShots() function of GameViewportClient.
void UFPOViewportClient::ProcessScreenShots(FViewport * InViewport)
{
if (GIsDumpingMovie || FScreenshotRequest::IsScreenshotRequested() || GIsHighResScreenshot) {
TArray<FColor> OutBMP;
FIntRect CropRect = FIntRect(CropPositionX, CropPositionY, (CropPositionX + CropSizeX), (CropPositionY + CropSizeY));
bool bScreenshotSuccessful = GetViewportScreenShot(InViewport, OutBMP, CropRect);
Next Step is to fill the alpha channel, right now with 255:
if (bScreenshotSuccessful) {
for (FColor& color : OutBMP)
{
color.A = 255;
}
}
But at this point, I want to fill the alpha with a mask.
So for the Console Exectue Command i use this command with the flag MaskEnabled:
HighResShot *ResolutionX(int32)xResolutionY(int32) Or Magnification(float) [CaptureRegionX(int32) CaptureRegionY(int32) CaptureRegionWidth(int32) CaptureRegionHeight(int32) MaskEnabled(int32) DumpBufferVisualizationTargets(int32) CaptureHDR(int32)]*
And added lines from FHighResScreenshotConfig::MergeMaskIntoAlpha:
if (bScreenshotSuccessful) {
TArray<FColor>* MaskArray = FScreenshotRequest::GetHighresScreenshotMaskColorArray();
if (MaskArray->Num() == OutBMP.Num()) {
for (int32 i = 0; i < MaskArray->Num(); ++i)
{
OutBMP*.A = (*MaskArray)*.R;
}
}
else {
for (FColor& color : OutBMP)
{
color.A = 255;
}
}
}
The problem is, that *MaskArray->Num() == OutBMP.Num() *never equals.
This results in a .png image with my isolated actor and a green background where instead I want transparency…
So what is the right way to get the ScreenshotMaskColorArray?