| View previous topic :: View next topic |
| Author |
Message |
jpspe
Joined: 22 Feb 2008 Posts: 10
|
Posted: Fri Feb 22, 2008 8:33 am Post subject: Change image colour |
|
|
Hi,
I have created a font system using images. The image consists of black letters with anti-aliasing. I would know like to change the colour of the image at runtime from black to say orange. The problem I'm having is to do with anti-aliasing. I worked out a quick way to subtract the differences between pixels, and the result is not bad... however, it is still not good enough.
How can I change the colour of my black anti-aliased image to another colour?
Thanks |
|
| Back to top |
|
 |
Insert_witty_name
Joined: 10 May 2006 Posts: 376
|
|
| Back to top |
|
 |
Art
Joined: 09 Nov 2005 Posts: 647
|
Posted: Sat Feb 23, 2008 12:17 pm Post subject: |
|
|
Split each pixel into R,G,B values as seperate bytes,
calculate mean average of each.
Use that value as the level of transparency for each pixel.
That's one way that works if the image is greyscale.
Art. _________________ If not actually, then potentially. |
|
| Back to top |
|
 |
danzel
Joined: 04 Nov 2005 Posts: 182
|
Posted: Sat Feb 23, 2008 1:33 pm Post subject: |
|
|
Some more possible ways:
Make your image white characters on a transparent background and use glcolor/gu-something-color or vertexes with a color component to colorise it when rendering.
Or you could use CLUTs with different color bands. |
|
| Back to top |
|
 |
jean

Joined: 05 Jan 2008 Posts: 489
|
Posted: Sat Feb 23, 2008 9:19 pm Post subject: |
|
|
| The canonical way of doing this is to save the entire charset as a whole image with the chars monospaced and drawn in white on a white background, delineated only with alpha. In your rendering functions you can use sprites (what in standard openGL is called billboarding or impostoring) with the desired letter (portion of the charset texture) mapped onto it and the desired color specified as the "vertex" color. Be sure to set the GE state machine properly (i.e. texture mapping on, alpha channel on, z-buffer off, etc..) |
|
| Back to top |
|
 |
jpspe
Joined: 22 Feb 2008 Posts: 10
|
Posted: Mon Feb 25, 2008 5:38 am Post subject: |
|
|
Thanks everyone for your input.
I am definitely using an image including all possible characters. I've already done all the work in regards to grabbing characters for the image and displaying...
So, essentially regardless of whether the image I'm displaying has a character in it or some other interesting picture, I need to accomplish the same thing, i.e.in layman terms transform the main colour of the image.
Jean, I will give this a try. I'm new to graphics so I'll probably get back with a 'how do I...'.
Thanks so far.
Josh |
|
| Back to top |
|
 |
jpspe
Joined: 22 Feb 2008 Posts: 10
|
Posted: Tue Feb 26, 2008 4:03 am Post subject: |
|
|
Hi Jean,
I managed to get a sample working on its own using sprites.
I currently draw png graphics on screen as GU_TRIANGLE_STRIP. So what I did was draw my image as normal, then after draw the sprite on top. The sprite would appear and the whole screen would suddenly go blank.
Is there some problem in using the two drawing methods together?
Thanks,
Josh |
|
| Back to top |
|
 |
jpspe
Joined: 22 Feb 2008 Posts: 10
|
Posted: Wed Feb 27, 2008 9:32 am Post subject: |
|
|
I really don't have time to get this working as I have loads of other tasks to do in this app. I'm willing to pay someone to create a few functions that will:
1. accept an image (with black characters on a white background) as an input and convert it to:
- White characters on an orange background
- Orange characters on a white background
- Black characters on a grey background
Now, the image has anti-aliasing, so this must be converted as well. I'm using the graphics.h library for basic image png loading and image drawing. I can provide the framework for you. If anyone can do this for me please contact me.
Thanks,
Josh |
|
| Back to top |
|
 |
|