如果指定了 CutBox,就截取屏幕上一小块,如果没有指定CutBox,就截取整屏。
// 截屏。
bool ScreenShots(UWorld* pWorld, const FBox2D* CutBox/*= nullptr*/)
{
if (pWorld == NULL)
{
return false;
}
UGameViewportClient* pViewport = Cast<UGameViewportClient>(
pWorld ? pWorld->GetGameViewport() : GEngine->GameViewport);
if (pViewport == NULL)
{
return false;
}
FVector2D vSize = FVector2D::ZeroVector;
pViewport->GetViewportSize(vSize);
TArray<FColor> Bitmap;
bool bScreenshotSuccessful = false;
TSharedPtr<SWindow> WindowPtr = pViewport->GetWindow();
if (FSlateApplication::IsInitialized())
{
TSharedRef<SWidget> WindowRef = WindowPtr.ToSharedRef();
FIntVector IntVector = FIntVector(vSize.X, vSize.Y, 0);
bScreenshotSuccessful = FSlateApplication::Get().TakeScreenshot(
WindowRef, Bitmap, IntVector);
}
for (FColor& Color : Bitmap)
{
Color.A = 255;
}
TArray<FColor>* RealMap = &Bitmap;
bool bNeedCut =
UWorld中的自定义屏幕截图功能:CutBox支持

最低0.47元/天 解锁文章
795

被折叠的 条评论
为什么被折叠?



