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: 93
Joined: Sat Jan 16, 2016 5:57 am
Location: India

save screen as bitmap file mac11

Post by Anil8753 »

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: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: save screen as bitmap file mac11

Post by ONEEYEMAN »

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

Thank you.
Anil8753
Experienced Solver
Experienced Solver
Posts: 93
Joined: Sat Jan 16, 2016 5:57 am
Location: India

Re: save screen as bitmap file mac11

Post by Anil8753 »

yes, I do not see wxAssert. Saved bmp is black.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: save screen as bitmap file mac11

Post by ONEEYEMAN »

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

Thank you.
User avatar
doublemax
Moderator
Moderator
Posts: 19114
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: save screen as bitmap file mac11

Post by doublemax »

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: 93
Joined: Sat Jan 16, 2016 5:57 am
Location: India

Re: save screen as bitmap file mac11

Post by Anil8753 »

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