dilip shirke
dilip shirke

Reputation: 87

How, when to capture image to file from framebuffer in Vulkan

Working on Vulkan triangle render code, where I want to save rendered image to file instead of rendering to window. So when should I read the framebuffer and how to write in file. I guess need to convert pixels which are in raw RGBA format to some known BMP or PNG format.

Upvotes: 3

Views: 1920

Answers (1)

ratchet freak
ratchet freak

Reputation: 48196

After the render pass you can copy the rendered image from the framebuffer image to a VkBuffer in RGBA format which you can then map and read on the CPU.

How to encode the image into BMP or PNG is outside the scope of Vulkan. Though for BMP you only need to create the correct header and then you can put the raw data right after it.

Upvotes: 3

Related Questions