Skip to content

Commit

Permalink
For consistency use png for macos
Browse files Browse the repository at this point in the history
  • Loading branch information
VZout committed Aug 24, 2023
1 parent f409d08 commit ac271cc
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 31 deletions.
24 changes: 0 additions & 24 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ edition = "2018"

[features]
default = ["image-data"]
image-data = ["core-graphics", "image", "winapi/minwindef", "winapi/wingdi", "winapi/winnt"]
wayland-data-control = ["wl-clipboard-rs"]
image-data = ["dep:core-graphics", "dep:image", "winapi/minwindef", "winapi/wingdi", "winapi/winnt"]
wayland-data-control = ["dep:wl-clipboard-rs"]

[dependencies]
thiserror = "1.0"
Expand All @@ -36,7 +36,7 @@ objc_id = "0.1"
objc-foundation = "0.1"
once_cell = "1"
core-graphics = { version = "0.22", optional = true }
image = { version = "0.24", optional = true, default-features = false, features = ["tiff"] }
image = { version = "0.24", optional = true, default-features = false, features = ["png"] }

[target.'cfg(all(unix, not(any(target_os="macos", target_os="android", target_os="emscripten"))))'.dependencies]
log = "0.4"
Expand Down
8 changes: 4 additions & 4 deletions src/platform/osx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,14 +227,14 @@ impl<'clipboard> Get<'clipboard> {
Some(_) | None => return Err(Error::ContentNotAvailable),
};

let tiff: &NSArray<NSObject> = unsafe { msg_send![obj, TIFFRepresentation] };
let png: &NSArray<NSObject> = unsafe { msg_send![obj, PNGRepresentation] };
let data = unsafe {
let len: usize = msg_send![tiff, length];
let bytes: *const u8 = msg_send![tiff, bytes];
let len: usize = msg_send![png, length];
let bytes: *const u8 = msg_send![png, bytes];

Cursor::new(std::slice::from_raw_parts(bytes, len))
};
let reader = image::io::Reader::with_format(data, image::ImageFormat::Tiff);
let reader = image::io::Reader::with_format(data, image::ImageFormat::Png);
match reader.decode() {
Ok(img) => {
let rgba = img.into_rgba8();
Expand Down

0 comments on commit ac271cc

Please sign in to comment.