forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Change image colour

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development
View previous topic :: View next topic  
Author Message
jpspe



Joined: 22 Feb 2008
Posts: 10

PostPosted: Fri Feb 22, 2008 8:33 am    Post subject: Change image colour Reply with quote

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
View user's profile Send private message
Insert_witty_name



Joined: 10 May 2006
Posts: 376

PostPosted: Fri Feb 22, 2008 1:26 pm    Post subject: Reply with quote

You need to use MODULATE. See my pgeFont library for more details.

http://insomniac.0x89.org/index.php?id=77
Back to top
View user's profile Send private message
Art



Joined: 09 Nov 2005
Posts: 647

PostPosted: Sat Feb 23, 2008 12:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
danzel



Joined: 04 Nov 2005
Posts: 182

PostPosted: Sat Feb 23, 2008 1:33 pm    Post subject: Reply with quote

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
View user's profile Send private message
jean



Joined: 05 Jan 2008
Posts: 489

PostPosted: Sat Feb 23, 2008 9:19 pm    Post subject: Reply with quote

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
View user's profile Send private message
jpspe



Joined: 22 Feb 2008
Posts: 10

PostPosted: Mon Feb 25, 2008 5:38 am    Post subject: Reply with quote

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
View user's profile Send private message
jpspe



Joined: 22 Feb 2008
Posts: 10

PostPosted: Tue Feb 26, 2008 4:03 am    Post subject: Reply with quote

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
View user's profile Send private message
jpspe



Joined: 22 Feb 2008
Posts: 10

PostPosted: Wed Feb 27, 2008 9:32 am    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group