close
The Wayback Machine - https://web.archive.org/web/20201114110127/https://github.com/OpenLiveWriter/OpenLiveWriter/issues/779
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

Can't paste images from Snip & Sketch #779

Open
xyzzer opened this issue Nov 26, 2018 · 2 comments
Open

Can't paste images from Snip & Sketch #779

xyzzer opened this issue Nov 26, 2018 · 2 comments

Comments

@xyzzer
Copy link

@xyzzer xyzzer commented Nov 26, 2018

Trying to paste an image from Snip & Sketch (the Snipping Tool replacement from Windows 10 October 2018 Update aka RS5) results in nothing happening.

Looking through the code I found this to be the root cause - ImageData is only created if there's a DIB in the clipboard. It does work with the Photos app because that one also puts an image file in the clipboard, which OLW is able to treat as image content, but it seems like it wouldn't work with most modern (UWP) apps that just call the standard DataPackage::SetBitmap()

/// <summary>
/// Image Data contains Image data that was parsed from the DataObject.
/// </summary>
public class ImageData
{
    /// <summary>
    /// Creates an ImageData
    /// </summary>
    /// <param name="iDataObject">The IDataObject from which to create the ImageData</param>
    /// <returns>The ImageData, null if no ImageData could be created</returns>
    public static ImageData Create(IDataObject iDataObject)
    {
        if (!OleDataObjectHelper.GetDataPresentSafe(iDataObject, DataFormats.Dib) && !OleDataObjectHelper.GetDataPresentSafe(iDataObject, DataFormats.EnhancedMetafile))
            return null;
        else
            return new ImageData(iDataObject);
    }

It starts working correctly if I change it to:
public static ImageData Create(IDataObject iDataObject)
{
if (!OleDataObjectHelper.GetDataPresentSafe(iDataObject, DataFormats.Dib) &&
!OleDataObjectHelper.GetDataPresentSafe(iDataObject, DataFormats.Bitmap) &&
!OleDataObjectHelper.GetDataPresentSafe(iDataObject, DataFormats.EnhancedMetafile))
return null;
else
return new ImageData(iDataObject);
}

Really though - it should check for all supported image types before giving up.

@xyzzer
Copy link
Author

@xyzzer xyzzer commented Nov 27, 2018

It also fails with other UWP apps such as Windows Mail or Paint 3D since the common UWP DataPackage::SetBitmap() method doesn't mark the bitmap as a DIB.

@xyzzer
Copy link
Author

@xyzzer xyzzer commented Nov 27, 2018

It works with the Photos app only because Photos also puts the image file reference in the clipboard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.