yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
screenshot_utils.h
Go to the documentation of this file.
1#ifndef YAZE_APP_CORE_SERVICE_SCREENSHOT_UTILS_H_
2#define YAZE_APP_CORE_SERVICE_SCREENSHOT_UTILS_H_
3
4namespace yaze::test {
5enum class ScreenshotFormat { kAuto, kPng, kBmp };
6} // namespace yaze::test
7
8#ifdef YAZE_WITH_GRPC
9
10#include <cstdint>
11#include <optional>
12#include <string>
13
14#include "absl/status/statusor.h"
15
16namespace yaze {
17namespace test {
18
19struct ScreenshotArtifact {
20 std::string file_path;
21 int width = 0;
22 int height = 0;
23 int64_t file_size_bytes = 0;
24};
25
26struct CaptureRegion {
27 int x = 0;
28 int y = 0;
29 int width = 0;
30 int height = 0;
31};
32
33// Validates format/path without creating files. Auto infers PNG/BMP from a
34// case-insensitive extension; an empty path/extension defaults to BMP.
35// Explicit formats reject mismatched extensions. Missing PNG support returns
36// Unimplemented, never a BMP file masquerading as PNG.
37absl::StatusOr<ScreenshotFormat> ResolveScreenshotFormat(
38 const std::string& path, ScreenshotFormat format = ScreenshotFormat::kAuto);
39
40// Captures the main renderer output before Present. Empty preferred_path uses
41// the application's screenshots directory. A missing extension is appended
42// for the resolved format. Legacy no-argument calls continue to produce BMP.
43absl::StatusOr<ScreenshotArtifact> CaptureHarnessScreenshot(
44 const std::string& preferred_path = "", bool reveal_to_user = true,
46
47// Captures a specific region of the renderer output.
48// Coordinates are framebuffer pixels, clipped by intersection with its bounds.
49// If region is nullopt, captures the full renderer.
50absl::StatusOr<ScreenshotArtifact> CaptureHarnessScreenshotRegion(
51 const std::optional<CaptureRegion>& region,
52 const std::string& preferred_path = "", bool reveal_to_user = true,
54
55// Captures the currently active ImGui window.
56absl::StatusOr<ScreenshotArtifact> CaptureActiveWindow(
57 const std::string& preferred_path = "", bool reveal_to_user = true,
59
60// Captures a visible main-viewport ImGui window by name. Missing, hidden,
61// collapsed, or detached windows fail rather than returning a full screenshot.
62absl::StatusOr<ScreenshotArtifact> CaptureWindowByName(
63 const std::string& window_name, const std::string& preferred_path = "",
64 bool reveal_to_user = true,
66
67} // namespace test
68} // namespace yaze
69
70#endif // YAZE_WITH_GRPC
71#endif // YAZE_APP_CORE_SERVICE_SCREENSHOT_UTILS_H_