How to obtain the system resolution under the (1920*1080) macOS operating system
This StackOverflow answer shows one way to do it in Swift, and you can use the core-graphics
crate to do basically the same thing in Rust
fn main() {
let mode = core_graphics::display::CGDisplay::main()
.display_mode()
.unwrap();
println!(
"{} x {}; {} x {}",
mode.width(),
mode.height(),
mode.pixel_width(),
mode.pixel_height()
);
}
I assume the unprefixed height and width are in points rather than pixels, but the difference between the properties is helpfully undocumented by Apple[1]
-
The unprefixed properties are even documented as returning pixels, even though the pixel_* properties return larger values than the unprefixed properties on my machine. Fun! âŠī¸
2 Likes
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.