Comments (6)
嗯嗯,hash算法有快慢的,如果是很大的图,就需要考虑这个hash算法的速度了
哦哦,这个我暂时没有注意到,您推荐的 xxhash_rust 这个算法库比较快是吧 😁,我可以换上试试
from clipboard-rs.
图片在不同的格式,不同大小,hash肯定也是不同的,本质上是图片内容的字节数组不一样
byte[]
感谢大佬提醒,这让我想到了用缩略图计算哈希,果然又能快出将近 60% 的时间 🤗
from clipboard-rs.
@ayangweb 我推荐你可以使用这个库,
我写个简单的例子
先在配置中增加依赖:
xxhash-rust = { version = "0.8.10", features = ["xxh3"] }
use clipboard_rs::{common::RustImage, Clipboard, ClipboardContext};
use xxhash_rust::xxh3::xxh3_64;
fn main() {
let ctx = ClipboardContext::new().unwrap();
let img = ctx.get_image();
match img {
Ok(img) => {
let hash = xxh3_64(&img.to_png().unwrap().get_bytes());
let hash_str = format!("{:x}", hash);
println!("hash={}", hash);
println!("hash_str={}", hash_str);
}
Err(err) => {
println!("err={}", err);
}
}
}
from clipboard-rs.
图片在不同的格式,不同大小,hash肯定也是不同的,本质上是图片内容的字节数组不一样 byte[]
from clipboard-rs.
@ChurchTao 谢谢大佬的回复,我这边也是查阅了一下 rust 相关的知识,实现思路也是跟您的一致!
use std::{ hash::{Hash, Hasher}, };
let ctx = ClipboardContext::new().unwrap();
let image = ctx.get_image().unwrap();
let bytes = image.to_png().unwrap().get_bytes().to_vec();
let mut hasher = DefaultHasher::new();
bytes.hash(&mut hasher);
let hash = hasher.finish();
from clipboard-rs.
嗯嗯,hash算法有快慢的,如果是很大的图,就需要考虑这个hash算法的速度了
from clipboard-rs.
Related Issues (20)
- Abnormal exit HOT 4
- Does the get_image Method Support Windows? HOT 12
- `get_files` Segmentation Fault when there is no files on clipboard HOT 1
- ClipboardContext 能否实现 Clone / Copy ? HOT 5
- Error: `The image format could not be determined` on Win11 HOT 2
- Bug: Cannot paste after writing image to clipboard (on Windows) HOT 2
- Bug: No transparent background for clipboard image read on Windows HOT 1
- Bug: Cannot read clipboard image on MacOS for screenshots taken by certain apps HOT 3
- `set_html()` doesn't update text. HOT 1
- 当写入html时,在Windows上长度似乎是有限制的,并且会被自动截断。截断的长度不固定 HOT 1
- 如何获取复制内容的 app 来源 HOT 9
- 在微信选中文字就会触发 `on_clipboard_change` HOT 4
- 重新复制 HTML 时,部分软件粘贴失效 HOT 15
- 如何触发富文本的复制 HOT 17
- linux 下 get_files()一直拿不到结果 HOT 8
- [bug] windows 系统 html 写入剪切板的问题 HOT 12
- 设置剪切板时图片失真,像素偏移 HOT 16
- 部分应用中复制时会触发两次on_clipboard_change HOT 4
- [bug] windows 复制内容频繁崩溃 HOT 17
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from clipboard-rs.