]>
git.saurik.com Git - wxWidgets.git/blob - wxPython/wx/lib/imageutils.py
1 #----------------------------------------------------------------------
2 # Name: wxPython.lib.imageutils
3 # Purpose: A collection of functions for simple image manipulations
9 # Copyright: (c) 2002 by
10 # Licence: wxWindows license
11 #----------------------------------------------------------------------
13 from __future__
import nested_scopes
18 Convert the given image (in place) to a grayed-out
19 version, appropriate for a 'disabled' appearance.
21 factor
= 0.7 # 0 < f < 1. Higher is grayer.
23 maskColor
= (anImage
.GetMaskRed(), anImage
.GetMaskGreen(), anImage
.GetMaskBlue())
26 data
= map(ord, list(anImage
.GetData()))
28 for i
in range(0, len(data
), 3):
29 pixel
= (data
[i
], data
[i
+1], data
[i
+2])
30 pixel
= makeGray(pixel
, factor
, maskColor
)
33 anImage
.SetData(''.join(map(chr, data
)))
36 def makeGray((r
,g
,b
), factor
, maskColor
):
38 Make a pixel grayed-out. If the pixel
39 matches the maskColor, it won't be
42 if (r
,g
,b
) != maskColor
:
43 return map(lambda x
: int((230 - x
) * factor
) + x
, (r
,g
,b
))