// Visual capture for screenshots and image comparison #pragma once #include #include #include namespace mosis::testing { // PNG image data struct ImageData { uint32_t width = 0; uint32_t height = 0; std::vector pixels; // RGBA format bool IsValid() const { return width > 0 && height > 0 && !pixels.empty(); } }; // Result of image comparison struct CompareResult { bool match = false; double diff_percent = 0.0; uint32_t diff_pixels = 0; ImageData diff_image; }; // Captures and compares screenshots class VisualCapture { public: VisualCapture() = default; // Capture current framebuffer to image ImageData CaptureFramebuffer(uint32_t width, uint32_t height) const; // Save image to PNG file bool SavePNG(const ImageData& image, const std::string& path) const; // Load PNG file to image ImageData LoadPNG(const std::string& path) const; // Compare two images CompareResult Compare(const ImageData& actual, const ImageData& expected, double threshold = 0.01) const; // Generate diff image (highlights differences) ImageData GenerateDiff(const ImageData& actual, const ImageData& expected) const; // Utility: flip image vertically (for OpenGL coordinate conversion) void FlipVertically(ImageData& image) const; }; } // namespace mosis::testing