Win32 clipboard and alpha channel images

后端 未结 2 1165
臣服心动
臣服心动 2021-01-02 06:00

My application should be able to copy 32-bit images (RGB + alpha channel) to the clipboard and paste these images from the clipboard. For this I plan to use CF_DIBV5

2条回答
  •  醉梦人生
    2021-01-02 06:53

    I was stuck on this problem for a while despite the detailed main answer. It would not seem to preserve alpha (even through a clipboard viewer).

    It turns out, the solution is as simple as this:

    1. export CF_DIB (no need for V5) with 32-bit pre-multiplied alpha
    2. and export the "PNG" format With that, it seemed to be able to paste in all applications I tested (Paint.NET, GIMP, LibreOffice, and so forth).

    Essentially, as long as alpha was pre-multiplied, alpha was preserved in CF_DIB in almost every program I used. In a rare one-off case, "PNG" was needed.

    To be clear: CF_DIBV5 was not needed.

提交回复
热议问题