Phoenix Logo

phoenix_title wx.lib.imageutils

This module contains a collection of functions for simple image manipulations.

Description

This module contains a collection of functions for simple image manipulations. The 2 functions defined here (grayOut, makeGray and stepColour) can be used to convert a given image into a grey-scale representation and to darken/lighten a specific wxPython wx.Colour.

Usage

Sample usage:

import wx
from wx.lib.imageutils import grayOut, stepColour

app = wx.App(0)

bmp = wx.ArtProvider.GetBitmap(wx.ART_INFORMATION, wx.ART_OTHER, (32, 32))
disabled_bmp = wx.Bitmap(grayOut(bmp.ConvertToImage()))

colour = wx.Colour(100, 120, 130)

# Darker
dark_colour = stepColour(colour, 50)

# Lighter
light_colour = stepColour(colour, 120)

app.MainLoop()

function_summary Functions Summary

grayOut Convert the given image (in place) to a grayed-out
makeGray Make a pixel grayed-out. If the pixel matches the maskColor, it won’t be
stepColour An utility function that simply darkens or lightens a

Functions



grayOut(anImage)

Convert the given image (in place) to a grayed-out version, appropriate for a ‘disabled’ appearance.

Parameters:anImage (wx.Image) – the image we want to convert to gray-scale.
Return type:wx.Image
Returns:The modified (greyed out) image.

Note

the image is converted in place, i.e. the input image will be modified to a greyed out version.



makeGray(rgb, factor, maskColor)

Make a pixel grayed-out. If the pixel matches the maskColor, it won’t be changed.

Parameters:
  • rgb (tuple) – a tuple of red, green, blue integers, defining the pixel wx.Colour;
  • factor (float) – the amount for which we want to grey out a pixel colour;
  • maskColor (tuple or wx.Colour.) – the mask colour.
Return type:

tuple

Returns:

An RGB tuple with the greyed out pixel colour.



stepColour(c, step)

An utility function that simply darkens or lightens a color, based on the specified step value. A step of 0 is completely black and a step of 200 is totally white, and 100 results in the same color as was passed in.

Parameters:
  • c (wx.Colour) – the input colour to be modified (darkened or lightened);
  • step (integer) – the step value.
Return type:

wx.Colour

Returns:

A new colour, darkened or lightened depending on the input step value.