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

Clipboard cannot handle transparent pixels #12

Closed
thanhph111 opened this issue Jun 22, 2021 · 5 comments · Fixed by #22
Closed

Clipboard cannot handle transparent pixels #12

thanhph111 opened this issue Jun 22, 2021 · 5 comments · Fixed by #22
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed Windows Related to Windows platform

Comments

@thanhph111
Copy link
Collaborator

Describe the bug

The transparent pixels in images copied from website to Blender and copied from Blender to another place are in wrong color (see the recordings below).

To Reproduce

Copy from website:

  1. Copy a transparent image from website.
  2. Go to Blender and paste as a reference, paste as a plane or paste as a node.
  3. The pasted image doesn't maintain correct transparent pixels.

Copy from Blender:

  1. Open a transparent image with Image Editor.
  2. Use Image > Copy to Clipboard.
  3. Paste it to another software like Microsoft Word.
  4. The pasted image doesn't maintain correct transparent pixels.

Expected behavior

Pasted images to or from Blender must be exactly the same as the original images.

Platform

Operating System:

  • OS: Windows
  • Version: 20H2

Blender:

  • Version: 2.83, 2.93

Screencast

Copy from website Copy from Blender
1 2

Additional context

I think it is not efficient to use normal PowerShell cmdlet as it is not built to handle this, we need to use more dedicated assemblies.

Here is the transparent image to test: Image.

@thanhph111 thanhph111 added bug Something isn't working help wanted Extra attention is needed Windows Related to Windows platform labels Jun 22, 2021
@thanhph111 thanhph111 pinned this issue Jun 22, 2021
b-init added a commit that referenced this issue Oct 11, 2021
Edited powershell cmdlets to work with transparency.
Added option to toggle transparency while copying to clipboard (as some softwares don't support this format)
Fixed grammatical confusion in "push" and "pull" naming scheme
@b-init
Copy link
Owner

b-init commented Oct 11, 2021

Got it working in the latest commit 43f92ed! (for both copy and paste)
But i've never used powershell scripting before and there probably are some newbie-doodoos. But it works well!
Would you like to take a look and make sure everything's right?

@thanhph111
Copy link
Collaborator Author

Cool! I've tried with System.Windows.Forms before but got nowhere. Didn't know it can work with PowerShell. I'm doing some tests now. Good job man.

Do you think it would be better to move this change to a separate branch so we can do some experiments without affecting the main? If you want, I'll do some polishing for this.

BTW, I admit the terms can be confusing at first. But since these push and pull methods belong to Clipboard, we will see from its perspective. So the push means that the Clipboard gives us the data (it pushes data away, to a files for example), and the pull means it takes images from us (it pulls the image towards itself and we can paste image from it later). I think I didn't explain it thoroughly in the docs so you might get it wrong. Sorry for that.

@b-init
Copy link
Owner

b-init commented Oct 12, 2021

Yeah another branch for it sounds better, I probably should've done that from the beginning. And I'm sure there's a lot to be polished in my cmdlet scripts so sure! thanks.

oh it was just too confusing when looking the push/pull methods because I was looking at it from blender's side, as that's more intuitive to me. Although your reasoning is fair, I'd still prefer the current way (43f92ed) because whenever we're using this method, it's "blender" executing those commands and hence push for pushing to clipboard from blender and pull for pulling from clipboard to blender makes more sense to me.
But using the other terminology shouldn't really be an issue anyway and you're free to change it back if that makes more sense with respect to the code.

@thanhph111
Copy link
Collaborator Author

thanhph111 commented Oct 12, 2021

I think your point of view is good, I just want to give a different perspective to make it more intuitive and easier to remember.

Because we usually write Clipboard.push and Clipboard.pull, we should think that the Clipboard performs the push or pull operation but not the Blender. So if we include Blender, we can think this way: "Blender tells the clipboard to write to a file (push) and then Blender imports that file" and "Blender saves an image to a file and tells the clipboard to read it (pull)". That's also the way the code runs so I think it's nice to be in that way.

I opened #22 to further discuss about this.

b-init added a commit that referenced this issue Oct 14, 2021
* Now works with transparency (#12)

Edited powershell cmdlets to work with transparency.
Added option to toggle transparency while copying to clipboard (as some softwares don't support this format)
Fixed grammatical confusion in "push" and "pull" naming scheme

* Revert push and pull name changes

* Updated Transparency Script

script now populates clipboard with both `Bitmap` and `PNG` data.

Got rid of the preference and old script entirely because setting 'Bitmap' data is equivalent to using the old method. Hence, no need to switch to it exclusively

Co-authored-by: Binit <[email protected]>
@thanhph111 thanhph111 unpinned this issue Oct 15, 2021
@thanhph111
Copy link
Collaborator Author

The PR #22 partially handle this issue, the rest is discussed in #23.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed Windows Related to Windows platform
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants