MCPcopy Create free account
hub / github.com/OpenRCT2/OpenRCT2 / WriteRTToFile

Function WriteRTToFile

src/openrct2/interface/Screenshot.cpp:56–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54uint8_t gScreenshotCountdown = 0;
55
56static bool WriteRTToFile(std::string_view path, const RenderTarget& rt, const GamePalette& palette)
57{
58 auto const pixels8 = reinterpret_cast<uint8_t*>(rt.bits);
59 auto const pixelsLen = rt.LineStride() * rt.height;
60 try
61 {
62 Image image;
63 image.Width = rt.width;
64 image.Height = rt.height;
65 image.Depth = 8;
66 image.Stride = rt.LineStride();
67 image.Palette = palette;
68 image.Pixels = std::vector<uint8_t>(pixels8, pixels8 + pixelsLen);
69 Imaging::WriteToFile(path, image, ImageFormat::png);
70 return true;
71 }
72 catch (const std::exception& e)
73 {
74 LOG_ERROR("Unable to write png: %s", e.what());
75 return false;
76 }
77}
78
79/**
80 *

Callers 4

ScreenshotDumpPNGFunction · 0.85
ScreenshotGiantFunction · 0.85
CommandLineForScreenshotFunction · 0.85
CaptureImageFunction · 0.85

Calls 3

LineStrideMethod · 0.80
WriteToFileFunction · 0.50
whatMethod · 0.45

Tested by

no test coverage detected