save screen as bitmap file mac11 Topic is solved

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
Anil8753
Experienced Solver
Experienced Solver
Posts: 92
Joined: Sat Jan 16, 2016 5:57 am
Location: India

save screen as bitmap file mac11

Post by Anil8753 » Tue Sep 15, 2020 11:42 am

I was using the following code to capture the screenshot of a wxWindow (on both Windows and MacOS).

Code: Select all

void CaptureScreenShot(wxWindow* pWin)
{
    wxClientDC bgdc(pWin);

    int width = bgdc.GetSize().GetWidth();
    int height = bgdc.GetSize().GetHeight();

    //Create a Bitmap that will later on hold the screenshot image
    //Note that the Bitmap must have a size big enough to hold the screenshot
    //-1 means using the current default colour depth
    wxBitmap bmpWin = wxBitmap(width, height, -1);

    wxMemoryDC memDC;
    memDC.SelectObject(bmpWin);
    memDC.Blit(0, 0, width, height, &bgdc, 0, 0);

    wxASSERT(bmpWin.IsOk());
    bmpWin.SaveFile("path to filesytem", wxBitmapType::wxBITMAP_TYPE_BMP);
}
On Mac11 (Bigsur) captured bitmap is black
Can someone pointout what is wrong with shared code snippet that causing Black bitmap on Mac11 Bigsur.
Till Mac 10.15 this code was working.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4364
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: save screen as bitmap file mac11

Post by ONEEYEMAN » Tue Sep 15, 2020 5:02 pm

Hi,
I presume you don't see an assert?

Thank you.

Anil8753
Experienced Solver
Experienced Solver
Posts: 92
Joined: Sat Jan 16, 2016 5:57 am
Location: India

Re: save screen as bitmap file mac11

Post by Anil8753 » Wed Sep 16, 2020 6:25 am

yes, I do not see wxAssert. Saved bmp is black.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4364
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: save screen as bitmap file mac11

Post by ONEEYEMAN » Wed Sep 16, 2020 7:05 am

Hi,
How did you build the library? What is your configure line?

Thank you.

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

Re: save screen as bitmap file mac11

Post by doublemax » Wed Sep 16, 2020 8:19 am

I don't think there is anything wrong in your code or your library. It's probably caused by a change in OS X. It might even be a privacy protection matter.

Try asking again on the wx-dev mailing list where the main author of the OSX port, Stefan Csomor might be able to answer.
Use the source, Luke!

Anil8753
Experienced Solver
Experienced Solver
Posts: 92
Joined: Sat Jan 16, 2016 5:57 am
Location: India

Re: save screen as bitmap file mac11

Post by Anil8753 » Thu Sep 17, 2020 4:58 pm

Thank you, Stefan helped me resolved this issue. wx3.1.4 (primarily focused on mac11 issues) has the fix.
I need to copy the wxBitmap wxWindowDCImpl::DoGetAsBitmap(const wxRect *subrect) const from src/osx/cocoa/utils.mm from 3.1.4 to my version

https://groups.google.com/g/wx-dev/c/KD ... PvhcIGBAAJ

Post Reply