1
\$\begingroup\$

This isn't a language-specific thing as far as I'm concerned. I was wondering what may be a quick way to change the COLOR of a certain on-screen element such as a button and its associated text.

I would assume there is a trick to making a graphics engine so maybe individuals pixels or groups of sprites can have their colors easily shifted. A lot of game interface buttons and such have this so you know when an event like a click has occurred.

Any pseudo code would be helpful and I am working in Android (not XML fluff), but again, this probably is not a very specific question, just an inquiry on how to go about this.

\$\endgroup\$

2 Answers 2

0
\$\begingroup\$

When i want to do something like this, I use white pixels form my images on the texture (usually flat shapes, and also for text). Then I use gl.glColor4f() to the color I want the item to appear in. When rendering, this color is blended with the color of the texture and because the texture items are white, the result is that the items are rendered with the color set by gl.glColor4f().

This is a very basic way to do that, but it has served me well in many cases. Just make sure to reset the color back to pure white with gl.glColor4f() once you are done, otherwise the last color will be applied to all textures.

Of course I am assuming that you are using OpenGL ES, since you did not specify.

\$\endgroup\$
1
  • \$\begingroup\$ No I'm not using OpenGL hehe hence the puzzling over gl.glColor4f(). \$\endgroup\$
    – A13X
    Commented Oct 18, 2013 at 2:44
0
\$\begingroup\$

So after searching with the question more clearly stated, I found the following link:

https://stackoverflow.com/questions/4251027/faster-way-to-set-a-png-bitmap-color-instead-of-pixel-by-pixel

Basically, I wanted to be able to change the text color, button colors, etc. and it looks like there are methods in the bitmap class to accomplish that (bitmap.extractAlpha() looks promising).

Thanks again for your help everyone.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .