Colour Swapping
Displaying 1-14 of 14 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Interference22

Is there a function in V3 for swapping one colour in an image for another? This would be really quite useful for user-customised textboxes in-game without needing to have hundreds of different images for all the different colour combinations.

I understand you can change individual pixels but how hard can it be to add a function like SwapColor(int RGB, int ReplaceRGB)?

Posted on 2004-06-10 09:48:44

mcgrue

Yes, it would be quite handy, and I've been moaning at zeromus for quite some time about it. Zero insists that it's very hard to do properly.

I told him to do it improperly in an expedient way, but Zero likes taking the long, hard, and never-finished route. ;)

Posted on 2004-06-10 10:51:49

RageCage

I assume you want to change the hue of an image. You might be able to find some kind of algorithm for that online. but if you just want to change textbox colors or something, why not use colorfilter()?

Posted on 2004-06-10 14:07:12

Omni

Why not just define a user-textbox color R, G, and B?



Or, why not make your own ChangeColor() function? Just loop through every pixel in an image--if it matches the target pixel, change it to the desired pixel.



As I side note, there was a ChangeColor() in V2.5, or V2kj. It was one of those. ...I think.

Posted on 2004-06-10 14:26:39

Interference22

I know I *could* code my own but it all seems a little untidy, could take a while to perform all those calculations (a whopping 24,000 for this image alone) and is something that could probably be done much easier.

Basically, what I want is for the purple colours in the image below:



.... to be interchangeable, so I the user could choose to have a red one, blue one etc.

Colour filter only does a few colour changing combinations, I want something a little more specific.

Posted on 2004-06-11 14:03:35

Zip

No reason you shouldn't draw that runtime. My advice:

Make four edge bitmaps from that one big one (ideally you'd do those runtime too)
Use a colour picker in a graphics program and write down the darker and lighter purple shades
Count the pixel width of each of those squares (gridsize)

In verge:
Create variables for the two shades: int msgboxdark, msgboxlight;
msgbox = NewImage(w, h);
RectFill(0, 0, w, h, msgboxdark, msgbox);
for (y = 4; y < h; y += gridsize) {
for (x = 4; x < w; x += gridsize) {
SetPixel(x, y, msgboxlight, msgbox); } }
Blit(0, 0, edgetop, msgbox);
Blit(0, 4, edgeleft, msgbox);
Blit(w-3, 4, edgeright, msgbox);
Blit(0, h-3, edgebottom, msgbox);

Run that once at the start, then if the user wants to change the colour:
FreeImage(msgbox);
msgboxdark = whatever;
msgboxlight = whateverabitlighter;
And call it again.

Zip

[edit: damn &_lt;]

Posted on 2004-06-11 14:36:32 (last edited on 2004-06-11 14:39:06)

Interference22

Quote:Originally posted by Zip

No reason you shouldn't draw that runtime. My advice:

Make four edge bitmaps from that one big one (ideally you'd do those runtime too)
Use a colour picker in a graphics program and write down the darker and lighter purple shades
Count the pixel width of each of those squares (gridsize)

In verge:
Create variables for the two shades: int msgboxdark, msgboxlight;
msgbox = NewImage(w, h);
RectFill(0, 0, w, h, msgboxdark, msgbox);
for (y = 4; y


I could render the border and then pattern out the grid in the middle but it still wouldn't fix the problem if I was using non-uniform shapes or a background that wasn't a pattern. It may well serve as a short-tem fix but when I design a few more textbox styles it's going to get horribly inconvenient. In short, a colour changer IS the way to go and would save me a whole lot of work.

Posted on 2004-06-11 14:42:56

Zip

It's a lot nicer doing funky effects runtime. Then you can set up as many styles as you want and let the user pick them.
eg.

#define STYLE_GRID1 0
#define STYLE_GRID2 1
#define STYLE_FADE1 2
#define STYLE_FISHSHAPE 4
etc.

Then where I have RectFill and SetPixel at the moment:
switch (msgboxstyle)
case STYLE_GRID1:
// current stuff
case STYLE_GRID2:
// something else
case //etc.

The ease of doing a wide variety of different effects in the code actually make it quicker than setting up something similar with bitmaps. And is more fun. And takes up less space for images. Try it! Please! :)

Zip

Posted on 2004-06-11 14:55:31

Zip

Quote:Originally posted by Interference22


I could render the border and then pattern out the grid in the middle but it still wouldn't fix the problem if I was using non-uniform shapes or a background that wasn't a pattern. It may well serve as a short-tem fix but when I design a few more textbox styles it's going to get horribly inconvenient. In short, a colour changer IS the way to go and would save me a whole lot of work.


Or if you want an alternative 'quick fix' make a mask of what the colour pixels you want to be able to change, then:
Blt (x, y, msgbox, screen);
Silhouette(x, y, whatevercolouryouwant, msgboxmask, screen);
More funky effects available like this, and you can create as many masks (alpha effects too?) as you like.

Zip

Posted on 2004-06-11 15:02:21

Interference22

An interesting proposition. I'm tempted to try it. We'll se how things go. Cheers for the suggestions, by the way.

Posted on 2004-06-11 15:20:06

Gayo

If anyone is willing to use a VC-made swapper and is just too lazy to code one, I used a Gayo-made replacer for the compo. You can find it in the Lufia-esque BS, in animation.vc. The name is ReplaceColor. However, it's awfully easy to do, so I'm assuming what you guys want is something that does it at the speed of C++, in which case you will just have to incessantly pester dev people, I guess.

Posted on 2004-06-11 15:47:12

Buckermann

If you would use a separate image for the inner body of your textbox, drawn only in light grey shades, you could use MixColor() with very nice results.

Posted on 2004-06-11 16:05:14

Interference22

Quote:Originally posted by Gayo

If anyone is willing to use a VC-made swapper and is just too lazy to code one, I used a Gayo-made replacer for the compo. You can find it in the Lufia-esque BS, in animation.vc. The name is ReplaceColor. However, it's awfully easy to do, so I'm assuming what you guys want is something that does it at the speed of C++, in which case you will just have to incessantly pester dev people, I guess.


Yes. Warp factor C++, Mr Sulu. Someone threaten to eat Zeromus unless he includes this feature.

Posted on 2004-06-13 00:42:23

Gayo

Threats don't work on zeromus any more than anything else does. The best way to make sure that zeromus' work gets done is to give it to someone other than zeromus.

Posted on 2004-06-13 05:01:03


Displaying 1-14 of 14 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.