b-init / ImagePaste

A simple Blender addon to grab images from your clipboard and paste as a reference image in viewport or onto the image editor.
GNU General Public License v3.0
251 stars 9 forks source link

Support working with transparent images on Windows #22

Closed thanhph111 closed 3 years ago

thanhph111 commented 3 years ago

Proposed changes

This pull request expects to solve the transparent images issue on Windows. Resolves #12.

b-init commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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.