"graying out" Icons

I have some character portrait icons in my game. What technique would I use to “gray” them out when a character is knocked out?
They are just images on DirectGUI buttons.

DirectButtons support multiple images, including one for when they are in a disabled state. See the “DirectButton” page in the manual for details and an example, and another thread I found.

Creating new versions that are more gray in your paint program would be the easiest thing to do, and would probably give the best-looking results.

I guess you could also try putting a 50% transparent gray card in front of it or something, if you like making things difficult.

David

Thx for the replies.

My app allows users to “mod” it by adding their own char portraits, so I can’t just create gray images of everything in advance (though I could for the action command icons).

I guess I’m off to gray cards.

I needed something like this for my game.
You can get the pixel data from your texture to a PNMImage object, make it grayscale then pass the pixel data from PNMImage to a new Texture object.

def makeGrayscaleTexture(texture):
	"""
	Takes a Texture object and returns a grayscaled version of it.
	"""
	
	# get data from Texture into PNMImage
	pnmimage = PNMImage()
	texture.store(pnmimage)
	
	# convert PNMIMage to grayscale
	pnmimage.makeGrayscale()
	
	# get data back to another Texture object
	newtexture = Texture()
	newtexture.load(pnmimage)
	
	return newtexture

Don’t get too confused with the PNMImage class name, “PNM” is there for historical reasons.

Thx for that. Will try it - very interesting.

Just wondering - Is there a way to change the “hue” of a texture to something else (like you can in paint programs).

I’m thinking of a slider which would allow the user to make a texture that looks red change to blue , etc.

You can write a shader to do this, or you can do it by processing each pixel on the CPU (via PNMImage). But there’s nothing built-in to do it for you.

David