# Export to Disk PNG results in blank

**URL:** <https://forums.unrealengine.com/t/export-to-disk-png-results-in-blank/2169168>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, CPP, question\
**Created:** [December 4, 2024, 4:55am UTC](https://forums.unrealengine.com/t/export-to-disk-png-results-in-blank/2169168 "2024-12-04T04:55:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SoulslayerEldin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SoulslayerEldin](https://forums.unrealengine.com/u/SoulslayerEldin)\
**Post date:** [December 4, 2024, 4:55am UTC](https://forums.unrealengine.com/t/export-to-disk-png-results-in-blank/2169168/1 "2024-12-04T04:55:11Z")

</div>

Hi,

I am trying to export render target as PNG images from C++. I can see the render target properly on a surface, however, ExportToDisk results in a blank image. Any pointers on debugging this?

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/8/4/38415c0a208c4770c413fdff6462530e30e25b67.jpeg)

Here’s the code to I used to setup the render target and screen capture component.

```auto
void AScreenCaptureCameraActor::SetupSceneCaptureComponment() {

	UCameraComponent* currentCamera = this->GetCameraComponent();
	FMinimalViewInfo minimalViewInfo;
	currentCamera->GetCameraView(0, minimalViewInfo); // first argument is delta time.

	mSceneCaptureComponent = mSceneCaptureActor->GetCaptureComponent2D();
	mSceneCaptureComponent->SetCameraView(minimalViewInfo);
	mSceneCaptureComponent->bAlwaysPersistRenderingState = false;
	mSceneCaptureComponent->CaptureSource = ESceneCaptureSource::SCS_FinalColorLDR;
	mSceneCaptureComponent->bCaptureOnMovement = false;
	mSceneCaptureComponent->bCaptureEveryFrame = false;
	mSceneCaptureComponent->MaxViewDistanceOverride = -1.0f;
	mSceneCaptureComponent->bAutoActivate = true;
	mSceneCaptureComponent->DetailMode = EDetailMode::DM_High;
}

void AScreenCaptureCameraActor::CaptureScene() {
	FTransform cameraWorldTransform = this->GetCameraComponent()->GetComponentTransform();
	mSceneCaptureComponent->SetWorldTransform(cameraWorldTransform);

	UTextureRenderTarget2D* renderTarget2D = NewObject<UTextureRenderTarget2D>();
	renderTarget2D->ClearColor = FLinearColor::Blue;
	renderTarget2D->InitCustomFormat(IMG_WIDTH, IMG_HEIGHT, PF_B8G8R8A8, true);
	renderTarget2D->RenderTargetFormat = ETextureRenderTargetFormat::RTF_RGBA8;

	UCameraComponent* currentCamera = this->GetCameraComponent();
	FMinimalViewInfo minimalViewInfo;
	currentCamera->GetCameraView(0, minimalViewInfo); // first argument is delta time.

	mSceneCaptureComponent->SetCameraView(minimalViewInfo);
	mSceneCaptureComponent->bAlwaysPersistRenderingState = false;
	mSceneCaptureComponent->CaptureSource = ESceneCaptureSource::SCS_FinalColorLDR;
	mSceneCaptureComponent->TextureTarget = renderTarget2D;

	mSceneCaptureComponent->CaptureScene();

	this->mScreenNeedsToBeCaptured = true;
}

```

---

<div class="post-metadata">

**Author:** ![Arodi007](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arodi007/32/1022275_2.png) [@Arodi007](https://forums.unrealengine.com/u/Arodi007)\
**Post date:** [December 4, 2024, 7:13am UTC](https://forums.unrealengine.com/t/export-to-disk-png-results-in-blank/2169168/2 "2024-12-04T07:13:24Z")

</div>

Try with RTF RGBA8 sRGB if that does anything.

---

<div class="post-metadata">

**Author:** ![SoulslayerEldin](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SoulslayerEldin](https://forums.unrealengine.com/u/SoulslayerEldin)\
**Post date:** [December 4, 2024, 2:06pm UTC](https://forums.unrealengine.com/t/export-to-disk-png-results-in-blank/2169168/3 "2024-12-04T14:06:26Z")

</div>

Thank you for the suggestion. It’s still blank with sRGB. Only difference i saw is that without the srgb, unreal editor was reporting “Detected Source Alpha: 1”. It does not say anything anymore.

I noticed one thing that the dumped image has all the channel values set to 0. I am now wondering whether the capturing timing has to do anything with it. Any chance that I tried to save before renderTarget got populated? Or may be it got cleared. I am still new with Unreal Engine. Any pointers on the lifecycle practices that I should watch out for?

---

<div class="post-metadata">

**Author:** ![Arodi007](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/arodi007/32/1022275_2.png) [@Arodi007](https://forums.unrealengine.com/u/Arodi007)\
**Post date:** [December 9, 2024, 5:26am UTC](https://forums.unrealengine.com/t/export-to-disk-png-results-in-blank/2169168/4 "2024-12-09T05:26:51Z")

</div>

Try to make the same setting as this one, it seem other people were facing the same issue [Saving render target to .png and exporting - #6 by Arodi007](https://forums.unrealengine.com/t/saving-render-target-to-png-and-exporting/1412755/6)
