Grey Blitting on Mac?

I'd guess that is has something to do with either the default color
depth of the bitmap, or the changes to the wxMac DC implementation.

I'd suggest, in no particular order, manually specifying the color
depth in the bitmap, trying a wxClientDC instead of a wxWindowDC, and
using wxDCs GetAsBitmap method instead of manually blitting.

···

On Dec 7, 2007 8:20 AM, Ed Leafe <ed@leafe.com> wrote:

        I've got a routine that creates a bitmap that is a screenshot of a
frame. The code is:

def getBitmap(self):
        dc = wx.WindowDC(self)
        rect = self.GetRect()
        bmp = wx.EmptyBitmap(rect.width, rect.height, -1)
        memdc = wx.MemoryDC()
        memdc.SelectObject(bmp)
        memdc.Blit(0, 0, rect.width, rect.height, dc, 0, 0)
        memdc.SelectObject(wx.NullBitmap)
        memdc.Destroy()
        return bmp

        This works great on Windows and Gtk, but on the Mac, it produces a
monochrome version of the frame. It is mostly black-and-white, but
does have some greys in it. Any idea why?

I'd guess that is has something to do with either the default color
depth of the bitmap, or the changes to the wxMac DC implementation.

  Something must have changed in the wxMac implementation, since this code has been working well for a few years now.

I'd suggest, in no particular order, manually specifying the color
depth in the bitmap,

  No change.

trying a wxClientDC instead of a wxWindowDC,

  No change

and using wxDCs GetAsBitmap method instead of manually blitting.

  When was this method added? I don't see a reference to it in the docs.

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

···

On Dec 7, 2007, at 11:44 AM, Chris Mellon wrote:

It was made the default in 2.8.

  OK, I'm using 2.8.4.0

It was added a few versions ago as a convenience wrapper for the
manual DC copying you were doing. I don't really expect it to help,
just if there were some subtlety to the bitmap construction I wasn't
aware of it might help.

It probably will help, in fact, it'll probably solve the problem. :slight_smile: wxWindowDC::GetAsBitmap() uses a special Carbon API to get a bitmap of the native window, which is the "official" way to do it using Carbon rather than using a DC. In CoreGraphics mode, Blit will only work with a wxMemoryDC, which is probably why he's getting weird results...

  Actually, it doesn't change a thing. I still get the black/white/grey version.

  I'm running this on a MacBook. Does the Intel hardware make a difference?

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

···

On Dec 7, 2007, at 1:37 PM, Kevin Ollivier wrote:

Hi Ed,

It was made the default in 2.8.

  OK, I'm using 2.8.4.0

It was added a few versions ago as a convenience wrapper for the
manual DC copying you were doing. I don't really expect it to help,
just if there were some subtlety to the bitmap construction I wasn't
aware of it might help.

It probably will help, in fact, it'll probably solve the problem. :slight_smile: wxWindowDC::GetAsBitmap() uses a special Carbon API to get a bitmap of the native window, which is the "official" way to do it using Carbon rather than using a DC. In CoreGraphics mode, Blit will only work with a wxMemoryDC, which is probably why he's getting weird results...

  Actually, it doesn't change a thing. I still get the black/white/grey version.

  I'm running this on a MacBook. Does the Intel hardware make a difference?

Ugh, no, it shouldn't, and if it does, it's a bug. Please try 2.8.7.1 if possible, and then if that doesn't work, file a bug on sf.net, as I think Stefan might be able to figure this out. Please submit a copy of the monochrome screenshot with the bug report too.

Panther, Tiger or Leopard, BTW?

Thanks,

Kevin

···

On Dec 7, 2007, at 11:06 AM, Ed Leafe wrote:

On Dec 7, 2007, at 1:37 PM, Kevin Ollivier wrote:

-- Ed Leafe
-- http://leafe.com
-- http://dabodev.com

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org