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

Support working with transparent images on Windows #22

Merged
merged 3 commits into from
Oct 14, 2021
Merged

Conversation

thanhph111
Copy link
Collaborator

Proposed changes

This pull request expects to solve the transparent images issue on Windows.
Resolves #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
@b-init
Copy link
Owner

b-init commented Oct 12, 2021

I think your point of view is good, 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 files (push) >and then 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.

I understand now. Looking from the clipboard's perspective does make more sense. Thanks for clarifying!

@thanhph111
Copy link
Collaborator Author

I also see the comment you added that says:

# script that supports transparency. Saves image to clipboard as PNG. However, lot of softwares don't accept this format.

So it turns out that some software does not allow us to paste PNG images? What software have you test and what is the result if we force paste them?

@b-init
Copy link
Owner

b-init commented Oct 12, 2021

Softwares like MS Paint, Discord, Adobe's Illustrator or Photoshop (although the story is completely different with adobe, I don't think they support transparency through clipboard in any sane way at all) don't support PNG format through clipboard, they expect it to be Bitmap. And some use Device-Independent-Bitmap with transparency support (which is quite complicated to get working from our code, as I've seen so far. Although I'll be looking into it deeper later when possible).
But softwares like Paint.net, PureRef do support PNG through clipboard, with transparency.

And I don't understand how we can force paste them?

@thanhph111
Copy link
Collaborator Author

Oh, I think I got the hang of how it works. Because on Windows each software takes a different type of image data, can we populate the clipboard as many types as we can, as I learned from this answer? Chrome does the same and it offers a lot of types, that's why its copied images can be pasted almost anywhere.

@b-init
Copy link
Owner

b-init commented Oct 12, 2021

Oh we can do that? How did I miss that!
Yes that's perfect. We should certainly do it for PNG and Non-transparent Bitmap atleast. But about DIB, I'm not sure it's worth the extra time and processing. I suppose most modern softwares that support transparency (and that need those blender output images to be put in with transparency for all practial purposes) would support PNG by default. What do you think?

@thanhph111
Copy link
Collaborator Author

Yeah I think the option should be checked by default and we will include more data types in the future. So with this PR, I think we will finish after adding one more Non-transparent Bitmap? I just don't know how to translate these C# code to PowerShell, yet. Other types we can add in next PRs.

@b-init
Copy link
Owner

b-init commented Oct 13, 2021

Yep that sounds good.
And then we shouldn't need the extra preference that I added at all right? it'd be just like it was before, just with transparency support for softwares that support PNG.

And I should be able to add it in the cmdlet myself. I'll work on that later today.

@thanhph111
Copy link
Collaborator Author

And then we shouldn't need the extra preference that I added at all right? it'd be just like it was before, just with transparency support for softwares that support PNG.

Yeah, I think we only need that preference when we don't have support for some popular software, otherwise we should keep it so as not to disappoint anyone who uses that software often.

And I should be able to add it in the cmdlet myself. I'll work on that later today.

Alright, just make it easy. You just need to push commits to this branch and it will update here.

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
@b-init b-init marked this pull request as ready for review October 14, 2021 10:00
@b-init b-init merged commit 3447b68 into main Oct 14, 2021
@b-init b-init deleted the windows-transparent branch October 14, 2021 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Clipboard cannot handle transparent pixels
2 participants