-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
For consistency use png on macOS #110
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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] }; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't believe NSImage supports this representation (and is causing a test failure), unlike UIImage which does. One alternative may be to wait for #106 to merge which switches to a different method of getting images from the clipboard. That way does support PNG like you'd want. |
||
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(); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes the feature flags in the docs a bit more readable as right now it shows
image
,core-graphics
andwl-clipboard-rs
as "features" but they are just optional dependenciesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW, this requires a bump to Rust 1.60 to support:
arboard
doesn't currently have an MSRV, and 1.60 is over a year old at this point, so I don't think its a big deal. Its also easy enough to rollback if it causes someone problems. I'm mentioning it just in case though.