43 lines
941 B
C++
43 lines
941 B
C++
#pragma once
|
|
|
|
#ifndef NOMINMAX
|
|
#define NOMINMAX
|
|
#endif
|
|
|
|
#include <windows.h>
|
|
#include <wincodec.h>
|
|
#include <wrl/client.h>
|
|
|
|
#include <cstdint>
|
|
#include <filesystem>
|
|
#include <string>
|
|
|
|
namespace XCEngine::UI::Editor::Host {
|
|
|
|
class D3D12WindowRenderer;
|
|
|
|
class D3D12WindowCapture {
|
|
public:
|
|
bool CaptureCurrentBackBufferToPng(
|
|
const D3D12WindowRenderer& windowRenderer,
|
|
const std::filesystem::path& outputPath,
|
|
std::string& outError);
|
|
void Shutdown();
|
|
|
|
private:
|
|
bool EnsureWicFactory(std::string& outError);
|
|
bool EncodePng(
|
|
const std::filesystem::path& outputPath,
|
|
const std::uint8_t* pixels,
|
|
UINT width,
|
|
UINT height,
|
|
UINT rowPitch,
|
|
REFWICPixelFormatGUID pixelFormat,
|
|
std::string& outError) const;
|
|
|
|
Microsoft::WRL::ComPtr<IWICImagingFactory> m_wicFactory = {};
|
|
bool m_wicComInitialized = false;
|
|
};
|
|
|
|
} // namespace XCEngine::UI::Editor::Host
|