Skip to content
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

Improve clipboard operation speed on Windows #32

Open
b-init opened this issue Jun 9, 2022 · 7 comments
Open

Improve clipboard operation speed on Windows #32

b-init opened this issue Jun 9, 2022 · 7 comments
Assignees
Labels
enhancement New feature or request Windows Related to Windows platform

Comments

@b-init
Copy link
Owner

b-init commented Jun 9, 2022

I'm working on a python utility to interact with the windows clipboard. It doesn't depend on 3rd party utilities and should be much faster and more flexible than our current approach.
The module (clipette) only supports RGB bitmap images now but I'm slowly working on transparency and supporting more formats. After it's good enough, we can work on integrating it with ImagePaste.
What do you think?

@b-init b-init assigned b-init and thanhph111 and unassigned b-init and thanhph111 Jun 9, 2022
@b-init b-init added enhancement New feature or request Windows Related to Windows platform labels Jun 9, 2022
@thanhph111
Copy link
Collaborator

Amazing, that's a new approach that I haven't thought about.

The script basically uses a shared library of Windows to access to OS APIs and then works with clipboard using them. I wonder if there's a way to do the same on macOS, a quick search brings me to nowhere.

@thanhph111 thanhph111 changed the title **Improve clipboard operation speed on _Windows_** Improve clipboard operation speed on Windows Jun 10, 2022
@b-init
Copy link
Owner Author

b-init commented Jun 10, 2022

For MacOS, there must be some official documentation about how a software is supposed to exchange clipboard data? (like there is for windows)
And if so, there might also be a way to port that to a python script, given the tool to make that possible exists? (like ctypes for directly accessing windows' clipboard utility)

@williamchange
Copy link
Contributor

On macOS this is done through the NSPasteboard https://developer.apple.com/documentation/appkit/nspasteboard which is what the pasteboard module uses, though I haven't looked further into whether this can be achieved like you have done through Windows using a shared library that's native on the platform

@atticus-lv
Copy link
Contributor

atticus-lv commented Jun 11, 2022

In my import addon , I use ctype to improve import speed. It is much faster(about 1ms-) than calling the shell (0.7s). But there is still some encode problem with it
https://github.com/atticus-lv/super_io/blob/master/clipboard/clipboard.py#L293

@b-init
Copy link
Owner Author

b-init commented Sep 19, 2022

Update: Transparency works now. I've added support for Bitmaps and PNG (both copying and pasting) which is most of what we'll need.

The current hurdles are integrating it with blender. The way I've used ctypes doesn't seem to work through blender, will need to figure that out.
Another problem is that blender doesn't support bitmaps with alpha. That's a problem because lot ot the times transparent images are only available on clipboard as bitmaps and I can only save that as a bitmap. But since blender can't read or convert this transparent bitmap, it's stuck.

@b-init
Copy link
Owner Author

b-init commented Sep 28, 2022

It's done!
Check out the clipette branch and let me know what you think @thanhph111

Sorry if I've not followed any formatting conventions or for the poor structure of the clipette module. I just don't think I properly understand those things yet.

@thanhph111
Copy link
Collaborator

Wow, amazing! This will be a significant upgrade. I'll take a look this weekend.
Don't worry about the minor format stuff, you've done most of the work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Windows Related to Windows platform
Projects
None yet
Development

No branches or pull requests

4 participants