Skip to content

Conversation

@robch
Copy link
Owner

@robch robch commented Dec 12, 2025

Summary

Implements native macOS screenshot capture using Core Graphics framework P/Invoke, validated against official dotnet/macios repository implementations.

Changes

  • src/cycod/cycod.csproj: Add OSX and LINUX compilation symbols
  • src/cycod/Helpers/ScreenshotHelper.cs:
    • Implement native macOS screenshot using CGDisplayCreateImage
    • Add P/Invoke declarations for CoreGraphics, CoreFoundation, and ImageIO frameworks
    • Proper memory management with CFRelease in finally blocks
  • src/cycod/FunctionCallingTools/ScreenshotHelperFunctions.cs: Enable for OSX platform
  • src/cycod/SlashCommands/SlashScreenshotCommandHandler.cs: Update platform checks for macOS support

Technical Details

  • Uses Core Graphics API (validated against Microsoft's ailab and dotnet/macios repos)
  • Writes PNG files using ImageIO framework ( APIs)
  • Proper CoreFoundation object lifecycle management
  • P/Invoke signatures match official .NET bindings from dotnet/macios

Testing

  • Builds successfully on Windows
  • Awaiting macOS CI validation

References

- Add OSX and LINUX compilation symbols to cycod.csproj
- Implement native macOS screenshot capture using Core Graphics framework
- Add P/Invoke declarations for CGDisplay, CoreFoundation, and ImageIO APIs
- Update platform support checks to include macOS alongside Windows
- Update error messages and descriptions to reflect macOS support
- Maintain proper memory management with CFRelease for Core Foundation objects

The implementation uses native macOS APIs without external dependencies:
- CGDisplayCreateImage for screen capture
- CGImageDestination for PNG export
- CFURL and CFString for file path handling

Tested: Build succeeds with no errors or warnings
@robch robch force-pushed the robch/2512-dec12-macos-screenshot branch from 008b8ce to c9d31ce Compare December 12, 2025 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants