Support not only CF_BITMAP but also "PNG" clipboard format.
Categories
(Core :: Widget: Win32, enhancement, P2)
Tracking
()
People
(Reporter: kageshiron, Unassigned)
References
(Blocks 2 open bugs)
Details
Attachments
(2 files)
69.19 KB,
image/png
|
Details | |
4.22 KB,
patch
|
Details | Diff | Splinter Review |
User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:89.0) Gecko/20100101 Firefox/89.0
Steps to reproduce:
This is a Windows 10 story, and does not apply to Linux and Mac.
In this proposal, "PNG Clipboard Format" is used to mean RegisterClipboardFormat("PNG").
<Problem1: Paste to firefox>
[1] Copy image with alpha channel from Paint.net
(or Copy from Paint 3D using Magic Select)
[2] Paste to editable. (e.g.: https://developer.mozilla.org/en-US/docs/Web/Guide/HTML/Editable_content )
Paint.NET: https://www.getpaint.net/
Paint 3D Magic Select: https://blogs.windows.com/windowsexperience/2017/07/12/announcing-more-updates-to-paint-3d-magic-select-enhancements-drawing-tools/
<Problem2: Copy from firefox>
[1] Right click some image
[2] Select "Copy Image"
Actual results:
<Paste to Firefox>
Firefox pasted the image WITHOUT alpha channel.
(Microsoft office can paste it with the alpha channel.)
<Copy from firefox>
Use InsiderClipboard to check the clipboard format.
https://www.nirsoft.net/utils/inside_clipboard.html
The following format are displayed:
text/html, text/_moz_htmlinfo, text/_moz_htmlcontext, Preferred DropEffect, HTML Format, CF_HDROP, CF_DIBV5, CF_DIB, application/x-moz-nativeimage, application/x-moz-file-promise-url, application/x-moz-file-promise-dest-filename
NOT contains PNG Clipboard format.
Expected results:
I suggest adding the PNG Clipboard Format. The PNG Clibpard Format simply contains the same data as the PNG file.
Background
CF_BITMAP, CF_DIB, CF_DIBV5 are very difficult for applications to process while preserving the alpha channel due to historical conveniences of Windows. PNG files are easy to process in any application and are highly compatible, even with transparency and animation.
Other applications
Microsoft is already using the PNG Clipboard Format on Windows and Office. They prefer PNG Clipboard Format to CF_BITMAP now
- Microsoft Office ( also have JFIF, GIF, image/svg+xml . see attached file)
- Snip & Sketch
- Paint 3D
- Paint.NET
I suggest that PNG be preferred over CF_BITMAP and CF_DIB because it have better data compatibility.
Comment 1•4 years ago
|
||
The Bugbug bot thinks this bug should belong to the 'Core::Web Painting' component, and is moving the bug to that component. Please revert this change in case you think the bot is wrong.
Updated•4 years ago
|
Comment 2•3 years ago
|
||
(In reply to kageshiron from comment #0)
This is a Windows 10 story, and does not apply to Linux and Mac.
Could you (or anyone else) clarify why this only applies to Windows? I'm not disagreeing, just hoping to get more clarity. Thanks!
@spohl there's some background in the equivalent change that was made in Chromium recently:
https://github.com/chromium/chromium/commit/e6f56636f365bdb210874bdbe63272f783792c7d
// On Windows there are 2 ways of writing a transparent image to the
// clipboard: Using the DIBV5 format with correct header and format or using
// the PNG format. Some programs only support one or the other. In particular,
// Word support for DIBV5 is buggy and PNG format is needed for it. Writing
// order is also important as some programs will use the first compatible
// format that is available on the clipboard, and we want Word to choose the
// PNG format.
Reporter | ||
Comment 5•3 years ago
|
||
Sorry for late response.
The clipboard is an OS-dependent mechanism. I am not familiar with Mac OSX or Linux.
So I wrote "does not apply to Linux and Mac."
Of course, PNG can be easily processed on Mac and Linux.
Comment 6•2 years ago
•
|
||
I wrote an experimental implementation of writing PNG to the clipboard (aka copying from Firefox) and I actually have issues finding an app where this produces any kind of noticeable difference. Sadly I don't own Microsoft Office. I haven't noticed anything in Paint 3D or Paint.net.
What is sort of interesting is that many apps seems to prefer CF_HDROP over CF_DIBV5 or "PNG". Chrome doesn't offer that format when copying images. This is also the cause of bug 1765665 and various duplicates.
Comment 7•2 years ago
|
||
Updated•2 years ago
|
Comment 8•2 years ago
•
|
||
I've recently been writing PNG copy/paste support for Bug 460969 and I'm intrigued about CF_HDROP as part of the compatibility matrix of image formats - I knew that some prefer RegisterClipboardFormatW(L"PNG") but I'm wondering which apps prefer CF_HDROP. I'm reasonably certain that offering PNG and DIBV5 (in BITFIELDS format specifically because it lets us specify the alphamask) and DIB is our best bet here but if there are common apps which don't support transparency via RegisterClipboardFormatW(L"PNG" )or CF_DIBV5 I would like to make an attempt at supporting copy/paste with them.
Description
•