| 630 | } |
| 631 | |
| 632 | void CaptureImage(const CaptureOptions& options) |
| 633 | { |
| 634 | Viewport viewport{}; |
| 635 | if (options.View.has_value()) |
| 636 | { |
| 637 | viewport.width = options.View->Width; |
| 638 | viewport.height = options.View->Height; |
| 639 | |
| 640 | auto z = TileElementHeight(options.View->Position); |
| 641 | CoordsXYZ coords3d(options.View->Position, z); |
| 642 | auto coords2d = Translate3DTo2DWithZ(options.Rotation, coords3d); |
| 643 | viewport.viewPos = { coords2d.x - ((options.Zoom.ApplyTo(viewport.ViewWidth())) / 2), |
| 644 | coords2d.y - ((options.Zoom.ApplyTo(viewport.ViewHeight())) / 2) }; |
| 645 | viewport.zoom = options.Zoom; |
| 646 | viewport.rotation = options.Rotation; |
| 647 | } |
| 648 | else |
| 649 | { |
| 650 | viewport = GetGiantViewport(options.Rotation, options.Zoom); |
| 651 | } |
| 652 | |
| 653 | if (options.Transparent) |
| 654 | { |
| 655 | viewport.flags |= VIEWPORT_FLAG_TRANSPARENT_BACKGROUND; |
| 656 | } |
| 657 | |
| 658 | auto outputPath = ResolveFilenameForCapture(options.Filename); |
| 659 | auto rt = CreateRT(viewport); |
| 660 | RenderViewport(nullptr, viewport, rt); |
| 661 | WriteRTToFile(outputPath, rt, gPalette); |
| 662 | ReleaseRT(rt); |
| 663 | } |
no test coverage detected