Download

Take a screenshot and use it in a widget as a gallery

Hi,

I need to take a screenshot and use it within a blueprint utility widget. This needs to happen in a packaged mobile game so im not sure if saving to a directory will work?
I have found the request screen shot function below but im now sure how to access that screenshot after it has been taken?


FScreenshotRequest::RequestScreenshot(false);

The function describes subscribing to the Viewports Onscreenshot captured delagte but im not sure how to do this.

I also ideally want the screenshot function to return a Texture2d component to be used in the widget unless there is something better?

In general the workflow is TakeScreenshot-> parse that screenshot into blueprint utility widget → Set an image to be the screenshot in the widget.

Thanks in advance.

Below is some code using file directory I tried but couldnt get the image to the utilty widget



const FString ImageDir = FString::Printf(TEXT("%s/%s"), *FPaths::ProjectDir(), TEXT("Content/ScreenShots"));
const FString ImgFileName = FString::Printf(TEXT("%s/Screenshot_3d.png"), *ImageDir);
FScreenshotRequest::RequestScreenshot(ImgFileName, false, false);



#include "Engine.h"

TArray<FColor> Bitmap; // rgb,rgb,rgb,rgb,rgb,rgb.........
GetViewportScreenShot(GEngine->GameViewport->Viewport, Bitmap); //get pixel
GEngine->GameViewport->Viewport->GetSizeXY().X //width
GEngine->GameViewport->Viewport->GetSizeXY().Y //height


Thanks for the info, I am unfamiliar with using Bitmaps, how would i use this the bitmap to get the screenshot into a blueprint?
Thanks in advance