Bug: Copy image to clipboard doesn't work anymore ...
Moderators: XnTriq, helmut, xnview
-
- Posts: 134
- Joined: Thu Feb 08, 2007 12:51 pm
Bug: Copy image to clipboard doesn't work anymore ...
... if the image has an alpha channel. Only if I remove the alpha channel the image can be copied, for example to Photoshop.
In the past it was so - I double click an image in the browser and it open. I choosed per Ctl-H the visibility of the transparency and per Ctr-A and Ctrl-C I copied the image to the clipboard. It was the perfect workflow for me. Please bring it back soon as possible.
Best-
Micha
In the past it was so - I double click an image in the browser and it open. I choosed per Ctl-H the visibility of the transparency and per Ctr-A and Ctrl-C I copied the image to the clipboard. It was the perfect workflow for me. Please bring it back soon as possible.
Best-
Micha
-
- Author of XnView
- Posts: 44593
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France
Re: Bug: Copy image to clipboard doesn't work anymore ...
What's happened? I have no problem with other apps
Pierre.
-
- Posts: 134
- Joined: Thu Feb 08, 2007 12:51 pm
Re: Bug: Copy image to clipboard doesn't work anymore ...
Tested here too - in other apps it works. Looks like I need to install the old XnView and stay there.
-
- XnThusiast
- Posts: 4138
- Joined: Sun Apr 29, 2012 9:45 am
- Location: Cheltenham, U.K.
Re: Bug: Copy image to clipboard doesn't work anymore ...
Are you possibly using an old version of Windows?Micha wrote:Looks like I need to install the old XnView and stay there.
Versions before 'XP are no longer formally supported, but whether that could possibly explain the issue I don't know...
-
- Posts: 134
- Joined: Thu Feb 08, 2007 12:51 pm
Re: Bug: Copy image to clipboard doesn't work anymore ...
No, I use Win 7 64 and I used XnView 1.97 for a long time without problems.
-
- Moderator & Librarian
- Posts: 6376
- Joined: Sun Sep 25, 2005 3:00 am
- Location: Ref Desk
Re: Bug: Copy image to clipboard doesn't work anymore ...
simoncbs ([url=http://newsgroup.xnview.com/viewtopic.php?p=110400#p110400]Win32: Alpha channel clipboard format[/url]) wrote:I have always struggled with 32-bit copy/paste, and I still use v1.97.8 as this is the last version that I can make it work in.
v1.97.8
32-bit Copy / Paste: works OK (as long destination image is also 32-bit)
32-bit Copy / Import clipboard: clipboard imported as 24-bit (without alpha layer), but then you can convert the newly created image to 32-bit, and paste the clipboard over it again, and now it works.
v1.98-v1.99
Neither of the above work for me (on XP SP3), I have tried every combination of alpha/32-bit settings I can find, and I just cannot get 32-pasting to work by any means.
I assume that the problem occurs in the pasting, not the copying, as I can copy from 1.98/99 then paste this into 1.97,
but I cannot copy (successfully) from 1.97 into 1.98/99.
[…]
UPDATE: Thank-you, the new v2.0.0 fixes these issues completely.
-
- Moderator & Librarian
- Posts: 6376
- Joined: Sun Sep 25, 2005 3:00 am
- Location: Ref Desk
Re: Bug: Copy image to clipboard doesn't work anymore ...
- Download logo.png.
- Run clipbrd.exe.
- Start XnView.
- Select logo.png in the browser.
- Go to Edit » Copy image data.
- Switch to ClipBook Viewer.
- Save the clipboard content as browser.clp.
Result: transparency replaced by white background - Switch to XnView.
- Open logo.png in the viewer.
- Go to Edit » Copy.
- Switch to ClipBook Viewer.
- Save the clipboard content as viewer.clp.
Result: all black
http://www.stackoverflow.com/questions/998655#998857 wrote:It might be like this article suggests, that the Clipboard object, working within Win32, is only able to manage bitmaps, which don't feature the transparent/partially transparent alpha channel. The OLE clipboard is more capable, it seems:
However, the netez was the best article I found on the topic. (beware I haven't tested this myself)
http://www.stackoverflow.com/questions/15689541#15691001 wrote:I'm sure there is a right way of storing the alpha in CF_DIBV5, but it really doesn't matter. Applications already handle it inconsistently, so if you want your application to play nicely with others you can't use CF_DIBV5.
I researched copying and pasting transparent bitmaps a while ago. My aim was to successfully paste a transparent bitmap into two versions of Office and GIMP. I looked at several possible formats:
CF_BITMAP
Transparency is always ignored.
CF_DIB
Using 32bpp BI_RGB in the usual 0xAARRGGBB format. GIMP supports this but nothing else does.
CF_DIBV5
GIMP doesn't support this.
"PNG"
Paste supported: GIMP, Word 2000, Excel 2000, Excel 2007 and PowerPoint 2007.
Paste unsupported: Word 2007 and OneNote 2007.
All of these applications successfully export "PNG" if you copy a bitmap.
However, Word and OneNote 2007 will paste a PNG file copied from Explorer. So I came up with the following:
Solution for Copying
Convert your transparent bitmap to PNG format.
Advertise the following clipboard formats:
"PNG" - the raw PNG data.
CF_DIB - for applications (like paint) that don't handle transparency.
CFSTR_FILEDESCRIPTOR - make the PNG look like a file. The file descriptor should have an invented filename with a ".png" extension.
CFSTR_FILECONTENTS - the contents must be exposed as an IStream; just using an HGLOBAL doesn't seem to work. The data is identical to the "PNG" data.
Having done this I could successfully paste transparent bitmaps into GIMP, Office 2000 and Office 2007. You can also paste the PNG directly into an Explorer folder.
Update
I realised that I've only answered half the question. This is great for copying, but no use if you want to paste from an application that only copies CF_DIBV5 (like Firefox).
I'd recommend that you use "PNG" if it's available, otherwise fall back to CF_DIBV5, treating it as premultiplied. This will correctly handle Word 2010 (which exports "PNG"), Firefox and Chrome. XnView only exports non-multiplied CF_DIBV5, so this won't work correctly. I'm not sure you can do any better.
lscf - A Tool for Exploring Clipboard Formats
This is the source of a tool for displaying a list of available clipboard formats. It can also write one to a file. I called it lscf. Create a win32 console application in Visual Studio and paste this source over the main function. It has one very minor bug: it never displays the "Unknown format" error if you mistype a format name.
Code: Select all
#include <Windows.h> #include <stdio.h> #include <tchar.h> #define ARRAY_SIZE(a) (sizeof(a) / sizeof(a[0])) LPCTSTR cfNames[] = { _T("CF_TEXT"), _T("CF_BITMAP"), _T("CF_METAFILEPICT"), _T("CF_SYLK"), _T("CF_DIF"), _T("CF_TIFF"), _T("CF_OEMTEXT"), _T("CF_DIB"), _T("CF_PALETTE"), _T("CF_PENDATA"), _T("CF_RIFF"), _T("CF_WAVE"), _T("CF_UNICODETEXT"), _T("CF_ENHMETAFILE"), _T("CF_HDROP"), _T("CF_LOCALE"), _T("CF_DIBV5") }; int LookupFormat(LPCTSTR name) { for (int i = 0; i != ARRAY_SIZE(cfNames); ++i) { if (_tcscmp(cfNames[i], name) == 0) return i + 1; } return RegisterClipboardFormat(name); } void PrintFormatName(int format) { if (!format) return; if ((format > 0) && (format <= ARRAY_SIZE(cfNames))) { _tprintf(_T("%s\n"), cfNames[format - 1]); } else { TCHAR buffer[100]; if (GetClipboardFormatName(format, buffer, ARRAY_SIZE(buffer))) _tprintf(_T("%s\n"), buffer); else _tprintf(_T("#%i\n"), format); } } void WriteFormats() { int count = 0; int format = 0; do { format = EnumClipboardFormats(format); if (format) { ++count; PrintFormatName(format); } } while (format != 0); if (!count) _tprintf(_T("Clipboard is empty!\n")); } void SaveFormat(int format, LPCTSTR filename) { HGLOBAL hData = (HGLOBAL)GetClipboardData(format); LPVOID data = GlobalLock(hData); HANDLE hFile = CreateFile(filename, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0); if (hFile != INVALID_HANDLE_VALUE) { DWORD bytesWritten; WriteFile(hFile, data, GlobalSize(hData), &bytesWritten, 0); CloseHandle(hFile); } GlobalUnlock(hData); } int _tmain(int argc, _TCHAR* argv[]) { if (!OpenClipboard(0)) { _tprintf(_T("Cannot open clipboard\n")); return 1; } if (argc == 1) { WriteFormats(); } else if (argc == 3) { int format = LookupFormat(argv[1]); if (format == 0) { _tprintf(_T("Unknown format\n")); return 1; } SaveFormat(format, argv[2]); } else { _tprintf(_T("lscf\n")); _tprintf(_T("List available clipboard formats\n\n")); _tprintf(_T("lscf CF_NAME filename\n")); _tprintf(_T("Write format CF_NAME to file filename\n\n")); } CloseClipboard(); return 0; }
-
- Author of XnView
- Posts: 44593
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France
Re: Bug: Copy image to clipboard doesn't work anymore ...
which PS version do you have?Micha wrote:Tested here too - in other apps it works. Looks like I need to install the old XnView and stay there.
Pierre.
-
- Posts: 134
- Joined: Thu Feb 08, 2007 12:51 pm
Re: Bug: Copy image to clipboard doesn't work anymore ...
Adobe Photoshop Version: 11.0.2 CS4
-
- Author of XnView
- Posts: 44593
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France
Re: Bug: Copy image to clipboard doesn't work anymore ...
i've sent you a PMMicha wrote:Adobe Photoshop Version: 11.0.2 CS4
Pierre.
-
- Posts: 134
- Joined: Thu Feb 08, 2007 12:51 pm
Re: Bug: Copy image to clipboard doesn't work anymore ...
test version works fine.
-
- Author of XnView
- Posts: 44593
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France
Re: Bug: Copy image to clipboard doesn't work anymore ...
ok, so it seems that photoshop doesn't like premultiplied component i'll add an option to use the old method...Micha wrote:test version works fine.
Pierre.
-
- Posts: 134
- Joined: Thu Feb 08, 2007 12:51 pm
-
- Author of XnView
- Posts: 44593
- Joined: Mon Oct 13, 2003 7:31 am
- Location: France
Re: Bug: Copy image to clipboard doesn't work anymore ...
i've sent you another PMMicha wrote:Thank you.
Pierre.
-
- Moderator & Librarian
- Posts: 6376
- Joined: Sun Sep 25, 2005 3:00 am
- Location: Ref Desk
Re: Bug: Copy image to clipboard doesn't work anymore ...
Freeware for analyzing clipboard content:
- Peter Johnson: Clipboard Format Spy
- Nir Sofer: InsideClipboard
- Jim Barry: Clipboard Spy (Softpedia)
- Karen Kenworthy †: Clipboard Viewer
- Comfort Software: Free Clipboard Viewer