"wxTheClipboard->SetData" not loading the alpha channel

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
Uwohm9
In need of some credit
In need of some credit
Posts: 4
Joined: Sun Feb 10, 2019 5:55 pm

"wxTheClipboard->SetData" not loading the alpha channel

Post by Uwohm9 » Fri Feb 21, 2020 11:06 pm

The code below doesn't load the alpha channel into the clipboard.
Am I doing something wrong?

Code: Select all

wxBitmap image(file_name, wxBITMAP_TYPE_ANY);
if (wxTheClipboard->Open()) {
	wxTheClipboard->SetData(new wxBitmapDataObject(image));
}
Now I'm losing my transparency in the image if I paste it somewhere.

I looked up for a solution on the internet but the only thing I found is an old ticket of a bug where some user had the exact same problem.
http://trac.wxwidgets.org/ticket/16198

If I look up in the file "src/osx/carbon/dataobj.cpp", nothing has yet changed while the milestone for this bug was 3.1.0.

User avatar
doublemax
Moderator
Moderator
Posts: 14897
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: "wxTheClipboard->SetData" not loading the alpha channel

Post by doublemax » Sat Feb 22, 2020 12:26 am

The ticket says that this was fixed. Which wxWidgets version do you use?

If it's an up-to-date version, reply to the ticket with instructions on how to reproduce the issue. Ideally with one of the samples that come with wxWidgets.
Use the source, Luke!

Uwohm9
In need of some credit
In need of some credit
Posts: 4
Joined: Sun Feb 10, 2019 5:55 pm

Re: "wxTheClipboard->SetData" not loading the alpha channel

Post by Uwohm9 » Sat Feb 22, 2020 8:02 pm

doublemax wrote:
Sat Feb 22, 2020 12:26 am
The ticket says that this was fixed. Which wxWidgets version do you use?

If it's an up-to-date version, reply to the ticket with instructions on how to reproduce the issue. Ideally with one of the samples that come with wxWidgets.
I had wxWidgets 3.0.4 but when I saw the ticket, I thought I will go with 3.1.3 to solve the bug. After installing the newer version, the bug still consisted. I immediately checked the dataobj.cpp files for the different OS's but the code was still the same back in version 3.0.4.

It's easy to reproduce, create a project with the following lines:

Code: Select all

const wxString file_name = "<path to any 32 bit image>";
wxBitmap image(file_name, wxBITMAP_TYPE_ANY);
if (wxTheClipboard->Open()) {
	wxTheClipboard->SetData(new wxBitmapDataObject(image));
}
After running the code, right click on a richtext document and click paste.
You will see the "wxTheClipboard->SetData(new wxBitmapDataObject(image))" didn't loaded the 32 bitmap properly, you will see the pixels that are normally transparent are now black pixels.

User avatar
doublemax
Moderator
Moderator
Posts: 14897
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: "wxTheClipboard->SetData" not loading the alpha channel

Post by doublemax » Sat Feb 22, 2020 9:10 pm

reply to the ticket with instructions on how to reproduce the issue
I mean to reply to the ticket on the bug tracker stating that the problem still persists for you.
Use the source, Luke!

Post Reply