wxWidgets / wxWidgets

Cross-Platform C++ GUI Library
https://www.wxwidgets.org/
5.77k stars 1.7k forks source link

Copy image (or bitmap with alpha) and Paste from clipboard into e.g. PowerPoint gives unexpected results (MSW) #24478

Open simbu11 opened 1 month ago

simbu11 commented 1 month ago

Bug description:

I'm experiencing an issue with copying an image (or bitmap with alpha) to the clipboard and then pasting it into PowerPoint (and other MS Office apps).

The issue can be seen in the wxImage sample (imagesample.exe): 1) Choose Clipboard->Copy Image as wxImage 2) Open PowerPoint and paste -> nothing happens (I tried paste special too). The behaviour seems independent of whether the copied image has an alpha channel.

Pasting DOES work in the Image sample Clipboard->Paste image as wxImage, and also in the Paint.net editor I have installed. If I subsequently choose Edit->Copy in Paint.net, I can paste the image directly into PowerPoint.

Choosing Copy test image as wxBitmap in imagesample.exe can then be pasted into PowerPoint when there is no alpha channel (i.e. the sample's test image). If the bitmap has an alpha channel, however, alpha seems to be lost when pasting into PowerPoint (shown by black background and pure black pixels where there was partial transparency in the wxBitmap.

Expected vs observed behaviour:

Although it is possible to paste the image into e.g. Paint.net, and from there into PowerPoint, it sure would be nice to be able to paste directly from my wx app into PowerPoint (as that is used by many users for presenting results).

Platform and version information

PBfordev commented 1 month ago

I can reproduce issue when using "Copy image as wxImage" with GIT master using Microsoft 365 MSO Version 2403 and others on Windows 10. Some programs can paste (Word, LibreOffice Write, GIMP), some cannot (Excel, PowerPoint, Paint, IrfanView).

NirSoft InsideClipboard reports the clipboard format used as PNG regardless of the test image file format. I did not have time to look into this any further.

vadz commented 4 weeks ago

This is weird because copying an image from Excel itself puts it on clipboard in several formats including PNG (also JFIF and GIF for some reason, as well as CF_BITMAP), but when we put it on clipboard in this format it indeed doesn't want to paste it.

We probably should make the data available in CF_BITMAP (or CF_DIB? or both?) formats too, it shouldn't be really difficult to do.

For now please use wxBitmapDataObject as workaround.