Skip to main content

SCScreenshotConfiguration

Struct SCScreenshotConfiguration 

Source
pub struct SCScreenshotConfiguration { /* private fields */ }
Expand description

Configuration for advanced screenshot capture (macOS 26.0+)

Provides fine-grained control over screenshot output including:

  • Output dimensions
  • Source and destination rectangles
  • Shadow and clipping behavior
  • HDR/SDR dynamic range
  • File output

§Examples

use screencapturekit::screenshot_manager::{SCScreenshotConfiguration, SCScreenshotDynamicRange};

let config = SCScreenshotConfiguration::new().expect("create screenshot configuration")
    .with_width(1920)
    .with_height(1080)
    .with_shows_cursor(true)
    .with_dynamic_range(SCScreenshotDynamicRange::BothSDRAndHDR);

Implementations§

Source§

impl SCScreenshotConfiguration

Source

pub fn new() -> Result<Self, SCError>

Create a new screenshot configuration

§Errors

Returns SCError::FeatureNotAvailable if the configuration cannot be created (requires macOS 26.0+)

Source

pub fn with_width(self, width: usize) -> Self

Set the output width in pixels

Source

pub fn with_height(self, height: usize) -> Self

Set the output height in pixels

Source

pub fn with_shows_cursor(self, shows_cursor: bool) -> Self

Set whether to show the cursor

Source

pub fn with_source_rect(self, rect: CGRect) -> Self

Set the source rectangle (subset of capture area)

Source

pub fn with_destination_rect(self, rect: CGRect) -> Self

Set the destination rectangle (output area)

Source

pub fn with_ignore_shadows(self, ignore_shadows: bool) -> Self

Set whether to ignore shadows

Source

pub fn with_ignore_clipping(self, ignore_clipping: bool) -> Self

Set whether to ignore clipping

Source

pub fn with_include_child_windows(self, include_child_windows: bool) -> Self

Set whether to include child windows

Source

pub fn with_display_intent( self, display_intent: SCScreenshotDisplayIntent, ) -> Self

Set the display intent

Source

pub fn with_dynamic_range(self, dynamic_range: SCScreenshotDynamicRange) -> Self

Set the dynamic range

Source

pub fn set_file_path( &mut self, path: impl AsRef<Path>, ) -> Result<&mut Self, InvalidScreenshotPath>

Set the output file path.

Accepts anything path-like (&str, String, &Path, PathBuf).

§Errors

Returns InvalidScreenshotPath and leaves the configuration unchanged if Foundation cannot represent the path.

Source

pub fn with_file_path( self, path: impl AsRef<Path>, ) -> Result<Self, InvalidScreenshotPath>

Set the output file path (builder pattern).

See set_file_path for how invalid paths are handled.

Source

pub fn without_file_path(self) -> Self

Clear any previously configured output file path.

Source

pub fn clear_file_path(&mut self) -> &mut Self

Clear any previously configured output file path.

Source

pub fn file_path(&self) -> Option<PathBuf>

Get the configured output file path, if one was set.

Source

pub fn width(&self) -> usize

Get the configured output width in pixels.

Source

pub fn height(&self) -> usize

Get the configured output height in pixels.

Source

pub fn shows_cursor(&self) -> bool

Whether the cursor will be drawn into the screenshot.

Source

pub fn source_rect(&self) -> CGRect

Get the source rectangle (the subset of the capture area to read).

Source

pub fn destination_rect(&self) -> CGRect

Get the destination rectangle (where the source is drawn in the output).

Source

pub fn ignore_shadows(&self) -> bool

Whether window shadows are excluded from the screenshot.

Source

pub fn ignore_clipping(&self) -> bool

Whether clipping to the window bounds is ignored.

Source

pub fn include_child_windows(&self) -> bool

Whether child windows are included in the screenshot.

Source

pub fn display_intent(&self) -> Result<SCScreenshotDisplayIntent, SCError>

Get the display intent.

Returns SCError::UnknownValue if the framework reported an intent this crate does not know about (a newer macOS adding a case).

Source

pub fn dynamic_range(&self) -> Result<SCScreenshotDynamicRange, SCError>

Get the dynamic range.

Returns SCError::UnknownValue if the framework reported a range this crate does not know about (a newer macOS adding a case).

Source

pub fn with_content_type( self, identifier: &str, ) -> Result<Self, InteriorNulError>

Set the content type (output format) using UTType identifier

Common identifiers include:

  • "public.png" - PNG format
  • "public.jpeg" - JPEG format
  • "public.heic" - HEIC format
  • "public.tiff" - TIFF format

Use supported_content_types() to get available formats.

§Errors

Returns InteriorNulError if identifier contains an interior NUL byte. Valid UTType identifiers never contain NUL bytes.

Source

pub fn content_type(&self) -> Option<String>

Get the current content type as UTType identifier

Returns None when no content type is set or the identifier does not fit in the transfer buffer; the bridge reports overflow as failure rather than handing back a truncated identifier.

Source

pub fn supported_content_types() -> Vec<String>

Get the list of supported content types (UTType identifiers)

Returns a list of UTType identifiers that can be used with with_content_type().

Common types include:

  • "public.png" - PNG format
  • "public.jpeg" - JPEG format
  • "public.heic" - HEIC format
Source

pub const fn as_ptr(&self) -> *const c_void

Trait Implementations§

Source§

impl Debug for SCScreenshotConfiguration

Available on crate feature macos_26_0 only.
Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for SCScreenshotConfiguration

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for SCScreenshotConfiguration

Available on crate feature macos_26_0 only.
Source§

impl Sync for SCScreenshotConfiguration

Available on crate feature macos_26_0 only.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.