<p>This is done in a very similar way of copying images to the gpu: (here some pseudo code:</p>
<pre><code>Create dest image in mappable memory so it can be read back later.
Transition source image to transfer read access.
Transition the dest image to transfer write access.
vkCmdBlit src to dest
Transition dest image to a access memory read/general layout
Transition src image back to original access/layout (assuming it will be used again)
memory map the dest image for reading back to the cpu
copy dest image to cpu memory
clean up
</code></pre>
<p>Use VkImageMemoryBarrier(2) for the transitions.</p>
<p>I am sure there are some good samples on how to do this out there.</p>

CC BY-SA 4.0
2022-07-07T01:34:39.510Z
E.g. https://github.com/SaschaWillems/Vulkan/blob/master/examples/renderheadless/renderheadless.cpp
TheBusyTypist
CC BY-SA 4.0
2022-07-06T11:20:45.980Z
2022-07-06T11:20:45.980Z
pmw1234
<p>I wish to render an image with my vulkan program and save it to local path. What's a good way to do this or has anyone done it before?
Thanks!</p>

<vulkan>
exporting the final image from Vulkan
Lily
# exporting the final image from Vulkan

(Asked by: username_0 on 2022-07-06)

I wish to render an image with my vulkan program and save it to local path. What's a good way to do this or has anyone done it before?
Thanks!

**Tags:** vulkan


---

## 1 answers

### Answer by username_1 on 2022-07-06. Score: 1

This is done in a very similar way of copying images to the gpu: (here some pseudo code:

```
Create dest image in mappable memory so it can be read back later.
Transition source image to transfer read access.
Transition the dest image to transfer write access.
vkCmdBlit src to dest
Transition dest image to a access memory read/general layout
Transition src image back to original access/layout (assuming it will be used again)
memory map the dest image for reading back to the cpu
copy dest image to cpu memory
clean up

```

Use VkImageMemoryBarrier(2) for the transitions.

I am sure there are some good samples on how to do this out there.

> **Comments:**
> **username_2**: E.g. https://github.com/SaschaWillems/Vulkan/blob/master/examples/renderheadless/renderheadless.cpp  

---

