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

Function CaptureImage

src/openrct2/interface/Screenshot.cpp:632–663  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

630}
631
632void 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}

Callers 1

captureImageMethod · 0.85

Calls 11

TileElementHeightFunction · 0.85
Translate3DTo2DWithZFunction · 0.85
GetGiantViewportFunction · 0.85
CreateRTFunction · 0.85
RenderViewportFunction · 0.85
WriteRTToFileFunction · 0.85
ReleaseRTFunction · 0.85
ApplyToMethod · 0.80
ViewWidthMethod · 0.80
ViewHeightMethod · 0.80

Tested by

no test coverage detected