| 8 | namespace OpenLoco::Scenario |
| 9 | { |
| 10 | void drawSavePreviewImage(void* pixels, Ui::Size size) |
| 11 | { |
| 12 | auto mainViewport = Ui::WindowManager::getMainViewport(); |
| 13 | if (mainViewport == nullptr) |
| 14 | { |
| 15 | return; |
| 16 | } |
| 17 | |
| 18 | const auto mapPosXY = mainViewport->getCentreMapPosition(); |
| 19 | const auto mapPosXYZ = World::Pos3(mapPosXY.x, mapPosXY.y, coord_t{ World::TileManager::getHeight(mapPosXY) }); |
| 20 | |
| 21 | Ui::Viewport saveVp{}; |
| 22 | saveVp.x = 0; |
| 23 | saveVp.y = 0; |
| 24 | saveVp.width = size.width; |
| 25 | saveVp.height = size.height; |
| 26 | saveVp.flags = Ui::ViewportFlags::hideTownNames | Ui::ViewportFlags::hideStationNames; |
| 27 | saveVp.zoom = ZoomLevel::half; |
| 28 | saveVp.viewWidth = size.width << saveVp.zoom; |
| 29 | saveVp.viewHeight = size.height << saveVp.zoom; |
| 30 | |
| 31 | const auto viewPos = saveVp.centre2dCoordinates(mapPosXYZ); |
| 32 | saveVp.viewX = viewPos.x; |
| 33 | saveVp.viewY = viewPos.y; |
| 34 | |
| 35 | Gfx::RenderTarget rt{}; |
| 36 | rt.bits = static_cast<uint8_t*>(pixels); |
| 37 | rt.x = 0; |
| 38 | rt.y = 0; |
| 39 | rt.width = size.width; |
| 40 | rt.height = size.height; |
| 41 | rt.pitch = 0; |
| 42 | rt.zoomLevel = saveVp.zoom; |
| 43 | |
| 44 | auto& drawingEngine = Gfx::getDrawingEngine(); |
| 45 | auto& drawingCtx = drawingEngine.getDrawingContext(); |
| 46 | |
| 47 | drawingCtx.pushRenderTarget(rt); |
| 48 | saveVp.render(drawingCtx); |
| 49 | drawingCtx.popRenderTarget(); |
| 50 | } |
| 51 | } |
no test coverage detected