wxBitmap - pixel value?

Hi - can anyone help me please?

If I load a mono bitmap into a wxBitmap, is there an easy way of finding out whether a pixel is set or unset. Or, for that matter, what value the pixel has in a bitmap of greater depth?

Mike Edmonds

If I load a mono bitmap into a wxBitmap, is there an easy way of finding

out whether a pixel is set or unset.

Or, for that matter, what value the pixel has in a bitmap of greater depth?

Hi

A few minutes longer would have had me figure out

        x = wx.Bitmap('black.bmp')
        y = wx.ImageFromBitmap(x)
        print y.GetGreen(10,10)
        print y.GetRed(10,10)
        print y.GetBlue(10,10)

0
0
0

and

        x = wx.Bitmap('white.bmp')
        y = wx.ImageFromBitmap(x)
        print y.GetGreen(10,10)
        print y.GetRed(10,10)
        print y.GetBlue(10,10)

255
255
255

That is good enough for me, but a single call would be better. Any takers?

Mike Edmonds

Mike Edmonds wrote:

>Or, for that matter, what value the pixel has in a bitmap of greater depth?
        x = wx.Bitmap('white.bmp')
        y = wx.ImageFromBitmap(x)
        print y.GetGreen(10,10)
        print y.GetRed(10,10)
        print y.GetBlue(10,10)

That is good enough for me, but a single call would be better. Any takers?

You can also select the bitmap into a wxMemoryDC and use DC.GetPixel:

**Warning: untested code:

dc = wxMemoryDC()
dc.SelectObject(bitmap)
color = dc.GetPixel()

NOw that I look at, however, if you want the separate r,g,b values,
you'll need to:

(r,g,b) = (color.Red, color.Green, color.Blue)

I think. Most of the wxPython methods that take a wxColor can also take
an (r,g,b) tuple, but it probably doesn't work the other eay around. So
the question becomes: is it better to create a wxImage or a wxMemoryDC?

-Chris

ยทยทยท

--
Christopher Barker, Ph.D.
Oceanographer
                                        
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov