Game Development Community

In-Game Image coloration, how?

by Robert Fritzen · in Torque 3D Professional · 07/16/2011 (1:32 pm) · 3 replies

Since source code is more than likely necessary here, I have a few questions regarding images.

So, lets say I have some image files. And with these images, I would like to be able to change the color of these images in my game using the color select gui.

All of the images are pure white with transparent backgrounds, so I would assume a color fill would probably work? Question is, how would I do this?

#1
07/16/2011 (5:35 pm)
You might be able to make use of GFXDrawUtil::setBitmapModulation() which changes the modulation color used when rendering an image. If your images are being drawn via a GUI control (i.e. GuiBitmapCtrl), you'd need a couple of simple engine modifications to make everything work. This method will probably require white (or greyscale) images for the best results.

Edit: Tinkered around for a couple of minutes and modified the GuiBitmapCtrl class to allow modulation color changes to be set from script. Modified GuiBitmapCtrl here: Link

Adds two new script methods to GuiBitmapCtrls: setColor() and getColor(). setColor takes a ColorI in the form of: "r g b alpha" (i.e. myImage.setColor("255 0 255 255");). getColor() simply returns the current modulation color (i.e. myImage.getColor();).

#2
07/17/2011 (9:35 am)
Thanks. Helps alot.
#3
08/28/2012 (2:35 pm)
Chris, would you mind re-posting that link, it appears dead and I need that again.

I tried writing my own using the setBitmapModulation(), but it appears to have zero affect on the bitmaps even when I call it with bitmap updates.