| 54 | uint8_t gScreenshotCountdown = 0; |
| 55 | |
| 56 | static 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 | * |
no test coverage detected