# How to let player draw on widget and save image?

**URL:** <https://forums.unrealengine.com/t/how-to-let-player-draw-on-widget-and-save-image/381449>\
**Category:** Blueprint\
**Tags:** draw, unreal-engine, CPP, Blueprint, question\
**Created:** [January 10, 2017, 3:32pm UTC](https://forums.unrealengine.com/t/how-to-let-player-draw-on-widget-and-save-image/381449 "2017-01-10T15:32:48Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![UnexpectedSquirt](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@UnexpectedSquirt](https://forums.unrealengine.com/u/UnexpectedSquirt)\
**Post date:** [January 13, 2017, 5:21pm UTC](https://forums.unrealengine.com/t/how-to-let-player-draw-on-widget-and-save-image/381449/2 "2017-01-13T17:21:35Z")

</div>

You want to be using render targets for this. You should watch Epic’s training stream to get a basic idea of how to set up blueprint render targets [Blueprint Drawing to Render Targets Overview | Live Training | Unreal Engine - YouTube](https://www.youtube.com/watch?v=1Z-V1Buk6z8)

As for saving / loading the render targets, that’s a little bit more complicated. There isn’t any out of the box functionality that I’m aware of to do this, so I’ve had to piece together my own solution in C++. The basic idea is that you want to read the pixels from the render target and write them to disk. You can then initialize a new render target with this saved data at a later time.

> **[A new, community-hosted Unreal Engine Wiki](https://forums.unrealengine.com/t/a-new-community-hosted-unreal-engine-wiki/141494)**
>
> After over a year in maintenance mode, the official Unreal Engine Wiki is now permanently offline. These resources now live on a new community-run Unreal Engine Community Wiki — ue4community.wiki! You will be able to find content from the official...

Skip to the bottom and look at the AHeightMapReader::UpdateBuffer() method in his code. Also take note of the “non blocking update buffer” method used beneath this. Reading pixels from a render target is a fairly expensive operation, and I personally found this solution to be quite necessary!

In my own implementation I am writing the pixels to my saved game object. To load my render target I then grab the pixels in my saved game object and initialize a new Texture Object from these pixels (see FImageUtils::CreateTexture2D()) One thing to be aware of when using this method is that it does contain editor only code, so you’ll probably want to have a look at Rama’s alternative version of this function which you can find here. [https://answers.unrealengine.com/questions/33571/fimageutilscreatetexture2d-causes-brief-hang-is-th.html](https://answers.unrealengine.com/questions/33571/fimageutilscreatetexture2d-causes-brief-hang-is-th.html)

Once you have a Texture2D that you’ve created from the saved render target data the rest is easy! You can just draw it to a fresh render target!

something like this:

```
UKismetRenderingLibrary::BeginDrawCanvasToRenderTarget(this, NewRT, RTCanvas, DrawSize, RTDrawContext);

RTCanvas->K2_DrawTexture(SavedRTTexture, FVector2D::ZeroVector, FVector2D(RTSize, RTSize), FVector2D::ZeroVector, FVector2D::UnitVector, FLinearColor(1.f, 1.f, 1.f, 1.f), EBlendMode::BLEND_Translucent);

UKismetRenderingLibrary::EndDrawCanvasToRenderTarget(this, RTDrawContext);

```

I hope all of that made some sense. Apologies if not, I’m still figuring it all out myself 🙂 It would surely be nice if Epic provided some better tools for handling render targets inside blueprint!

---

_[View the full topic](https://forums.unrealengine.com/t/how-to-let-player-draw-on-widget-and-save-image/381449)._
