Giter Club home page Giter Club logo

Comments (9)

neighthan avatar neighthan commented on May 24, 2024

So, the images in question are copy-pasted and have a transparent background. I'm using a workaround now where I explicitly set the background to be white; then things work fine with pasting the image using this extension. So, I guess the problem is how transparent backgrounds are handled? I think using white instead of black for the background color when there is none would make more sense. If this is easy to change, it would be a nice fix. Otherwise, I'm content with my explicitly white instead of transparent background workaround for now.

from vscode-paste-image.

mushanshitiancai avatar mushanshitiancai commented on May 24, 2024

Hello, What operating system do you use?

from vscode-paste-image.

neighthan avatar neighthan commented on May 24, 2024

Windows 10. I don't know that it matters, but I copy the images out of a Jupyter notebook. The notebook server is running on an Ubuntu machine, but I access the client from Windows.

from vscode-paste-image.

mushanshitiancai avatar mushanshitiancai commented on May 24, 2024

@kivle Hello friend, do you know why?

In file res/pc.ps1:

$img = [Windows.Clipboard]::GetImage()
$fcb = new-object Windows.Media.Imaging.FormatConvertedBitmap($img, [Windows.Media.PixelFormats]::Rgb24, $null, 0)

It get bitmap from clipboard with Rgb24 mode. Rgb24 it seems without aplha value, so get a black backgroud?

@neighthan Could you run res/pc.ps1(powershell script) in your Win10, and test with Rgb24 and Rgba64?

from vscode-paste-image.

neighthan avatar neighthan commented on May 24, 2024

Yes, using Rgba64 instead of Rgb24 fixes this issue!

from vscode-paste-image.

neighthan avatar neighthan commented on May 24, 2024

Okay, the issue seems a bit more complicated. If I copy + paste an image from a Jupyter notebook, it has the black background unless I use Rgba64, then it works. But if I paste in an image that I copied from a screenshot tool, using Rgb24 works and Rgba64 gives an empty image. I assume that the screenshot tool is only copying an RGB image to the clipboard instead of RGBA. Thus a proper solution to this would need to determine when to use each of these - any idea how to do that?

Or, if that's difficult, one workaround might be to have two separate commands that can be bound - one which uses Rgb24 for pasting and the other for Rgba64. Keeping Rgb24 as the default would mean nothing is broken for existing users, and anybody who has RGBA images can then just bind the new command to a different shortcut. One command that's smart about the image encoding would be nicer, but I'd be fine with two commands if that leads to a faster solution.

from vscode-paste-image.

neighthan avatar neighthan commented on May 24, 2024

I have no Powershell experience, but I used the lines from your script to get images from the clipboard to test on. For both an image that pastes properly with Rgba64 and for one that doesn't, Powershell has the same $img.Format (Bgra32). I tried using Bgra32 instead of Rgba64, but it also gives a blank image. If Powershell says the format for the two images is the same, I'm not sure what's wrong / how to detect which method to use.

from vscode-paste-image.

mushanshitiancai avatar mushanshitiancai commented on May 24, 2024

Hello, thank you for you research.

I use Rgba64 test in my windows, and it's ok for normal png or png with transparent background.

I publish a new version(1.0.3). You can try it!

from vscode-paste-image.

GutoSchettini avatar GutoSchettini commented on May 24, 2024

Hi. I have this issue, copying from Jupyter Lab to MS-Word...

Please, could someone be more clear about how to fix it? I'm not familiar (or better saying, completely ignorant!) with PowerShell operations... how to change RGB24 to RGBA64?

thanks

from vscode-paste-image.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.