Opened 2 months ago

Last modified 2 months ago

#18627 new defect

Cannot create bitmaps of views on OSX/Catalina

Reported by: dkulp Owned by:
Priority: normal Milestone:
Component: wxOSX Version: 3.1.3
Keywords: Cc:
Blocked By: Blocking:
Patch: no


While trying to track down an issue for why wxSmith doesn't work in CodeBlocks on OSX, I've managed to track down the first issue to wxWindowDCImpl::DoGetAsBitmap no longer works on OSX. The problem seems to be that the line:

if ( [rep respondsToSelector:@selector(CGImage)] )

returns false and it then goes into the block below it which has a "TODO" in it. It returns the default (all black) wxBitmap. Thus, it does not look we can grab the window contents on OSX anymore.

Change History (2)

comment:1 Changed 2 months ago by vadz

I'm not 100% sure but I think Stefan said in the past that this just wasn't supported any more. If you, or anybody else, knows of any way to work around this, please let us know.

If not, perhaps we could at least implement some API allowing to get a bitmap of a native control? E.g. in wxMSW we could use WM_PRINT for this and maybe Cocoa views can be rendered onto memory bitmaps too somehow?

comment:2 Changed 2 months ago by vadz

Hmm, looking at the comment in the code, it seems that CGWindowListCreateImage() could be used to implement this. Could anyone try making this work?

Note: See TracTickets for help on using tickets.