SRL Archive - News and General

Understanding SCAR Color Code


Yakman

2006-10-04 11:31:11

Ok, this thread is an attempt to make people understand SCAR color code,

i made this script a long time ago so i could understand it, see how very few other people could, i decided to post it here,

ever since i learnt about this, it has changed the way i think about Color Finding, escpecially tolerance, i now belive that Autocolor, or at least color updating it a must!

Basicly what the script does it display a color, then it adds 1 to the color and display it again

Example: Color := Color + 1

Sumilion

2006-10-04 15:24:46

Finally, it's published ;), this won't be very usefull for most people, but i'm sure some of us can use it quite well ;)

WhiteShadow

2006-10-04 22:58:19

Wow, I never knew about this. Thanks alot, Yakman.

Although, I rarely use color in my script. Bitmaps. xP Unless the color is very distinguished like iron ore in a varrock mine.

But thanks for the bit of information. :spot:

Freddy1990

2006-10-05 02:29:43

I'm kinda confused what exactly this is supposed to make me understand…
Scarcolors are just standard wincolors u know

Yakman

2006-10-05 11:15:43

freddy, i was sort of expecting you to know, i do know they are just windows colors, like i said in the script, iv seen them used in Ms Access

the script shows people the way the colors are laid out, like every 255 colors its seems to go back but slightly brighter

before i made this script i used to think that the colors went from 0 to 16777215, getting lighter with each added color, i thought that you could write these colors into Ms Paint and you would get it

anyway, i was wrong and this script showed me what was right, im sure other scripters could benifit from this

also, kaitnieks said that tolerance can be anything from 0 to 255, it seems 255 is an imporant number when it come to WinColors

Mutant Squirrle

2006-10-05 15:31:43

lol i didnt read this but it seems like you guys dont get colors?

The way scar finds colors and uses tolerance is simple it simply grabs the RGB values and adds them (side by side) together usually creating freaky long strings of integers

Tolerance just finds similar RGB values and says okay same color. not really that complex lol so what does this program do again? forces it to figure out what the colors RGB value is?

Freddy1990

2006-10-05 16:09:37

From: Yakman
freddy, i was sort of expecting you to know, i do know they are just windows colors, like i said in the script, iv seen them used in Ms Access

the script shows people the way the colors are laid out, like every 255 colors its seems to go back but slightly brighter

before i made this script i used to think that the colors went from 0 to 16777215, getting lighter with each added color, i thought that you could write these colors into Ms Paint and you would get it

anyway, i was wrong and this script showed me what was right, im sure other scripters could benifit from this

also, kaitnieks said that tolerance can be anything from 0 to 255, it seems 255 is an imporant number when it come to WinColors


Well of course i know how they work and everything, i didn't spend a year working with them for nothing…
And as mutant said, the 255 max tolerance is tied in with the rgb values

t3h ub3r k1tten

2006-10-06 15:35:03

Very nice :D

For an indepth look at the syntax, ask ruler (creator of i-bot)
In his i-bot it has scar color in the pixel browser.

Mutant Squirrle

2006-10-06 16:22:20

lol pretty much everyone knows how kait made it get colors and yes freddy i know…

canadarules

2006-10-16 22:15:35

Hello canadarules it appears that you have not posted on our forums in several weeks, why not take a few moments to ask a question, help provide a solution or just engage in a conversation with another member in any one of our forums?


Okay. I WILL engage in a conversation in one of the forums (I picked this one). The way I understood colours in SCAR is as a 6-character RGB hexadecimal, or base16, value converted into decimal form, or base10, and then provided.

For example, pure white is 16777215. After converting it into hexadecimal, you get FFFFFF. Because it's an RGB value, (red, green, blue), you divide it into three equal sections, one per color.

Red - FF
Green - FF
Blue - FF

You then convert back into decimal, and get your RGB value.

(255, 255, 255)

256 ^ 3 gives 16 777 216, the highest possible value. (It's 256 not 255, because you need to count 0 as a possible value).
255 is the maximum value used because it's the highest in an 8-bit scenario, and after 8-bit you have to go to 16-bit, and Kait probably felt that 8-bit gave enough of a colour range. 255 converted into binary (base2) goes to 11111111, taking exactly 8 on/off switches. Bit-count usually goes up by powers of 2, so to be more accurate you would go to 16-bit, which would give you 65 536 possible values of R, G, and B, with 2.81474977E14 colour choices, which becomes overkill. 4-bit would give you only 16 possible values of R, G, and B, or 4 096 possible colours, which isn't enough on a computer.

Also, 255 is the highest number to fit in an unsigned byte. A byte is 8 bits, and a bit is a single on/off switch. Unsigned just means it can't be negative, because signed would need one of the switches to represent positive/negative, giving you a range of -127 to 127.

If you're wondering why I posted all this in a 10-day old thread, well, it's at the top of the list, and Mutant posted in it, so I felt obliged to post.

Mr. Freeweed

2006-10-17 03:02:40

From: canadarules
Okay. I WILL engage in a conversation in one of the forums (I picked this one). The way I understood colours in SCAR is as a 6-character RGB hexadecimal, or base16, value converted into decimal form, or base10, and then provided.

For example, pure white is 16777215. After converting it into hexadecimal, you get FFFFFF. Because it's an RGB value, (red, green, blue), you divide it into three equal sections, one per color.

Red - FF
Green - FF
Blue - FF

You then convert back into decimal, and get your RGB value.

(255, 255, 255)

256 ^ 3 gives 16 777 216, the highest possible value. (It's 256 not 255, because you need to count 0 as a possible value).
255 is the maximum value used because it's the highest in an 8-bit scenario, and after 8-bit you have to go to 16-bit, and Kait probably felt that 8-bit gave enough of a colour range. 255 converted into binary (base2) goes to 11111111, taking exactly 8 on/off switches. Bit-count usually goes up by powers of 2, so to be more accurate you would go to 16-bit, which would give you 65 536 possible values of R, G, and B, with 2.81474977E14 colour choices, which becomes overkill. 4-bit would give you only 16 possible values of R, G, and B, or 4 096 possible colours, which isn't enough on a computer.

Also, 255 is the highest number to fit in an unsigned byte. A byte is 8 bits, and a bit is a single on/off switch. Unsigned just means it can't be negative, because signed would need one of the switches to represent positive/negative, giving you a range of -127 to 127.

If you're wondering why I posted all this in a 10-day old thread, well, it's at the top of the list, and Mutant posted in it, so I felt obliged to post.


Thats about the same thing my assembly book tells you on its first 2 pages after intro =)
Dont ask me why I read the whole boring ass book. I went to class 7 times during the whole semester and still got an A and snored when I was there. ;)

Mutant Squirrle

2006-10-17 13:21:23

thanks canada im pretty sure that explained it straight out in the open

Boreas

2006-10-22 14:53:15

So I've been working on this color stuff today and here's what I came up with.

I found as canada said, you can convert a color into hex and get a 6 character hex string. The first 2 characters are the hex value of the blue component, last 2 red, middle green. So I made a script to demonstrate this. The script converted SCAR color to hex, split into 3, and converted back to decimal, and did the reverse. I went into paint, made a custom color, took note of the red, green, and blue values, and used the scar color picker to get the color. Armed with this infomation I was able to convert from RGB to SCAR and check if it was correct. Then I noticed a problem, when any of the RGB values were low, the hex string was less than 6 characters. This is how hex values work:

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0 1 2 3 4 5 6 7 8 9 A B C D E F

As you can see the first few are only 1 character, theres really a 0 before each one (0F etc) which would up hold the 6 character length, but these 0's get lost in the process. So the hex values were less than 6 chars, which meant that finding the red section gave an error, because strget was looking for the 6th, and even if there was no error, there others were inaccurate because you dont know if 5FFFB is 5 FF FB(yellow) or 5F FF B(green).

So I found a new way to convert that doesn't use hex, in fact it does almost the same thing that hex does but skips over the hex part. Here are the functions I wrote:
type rgbcolor =record
red,green,blue:integer;
end;

function color2rgb(color:integer):rgbcolor;
begin
result.red:=(color mod 256);
result.green:=((color/256) mod 256);
result.blue:=((color/256) / 256);
end;

function rgb2color(rgb:rgbcolor):integer;
begin
result:=(((rgb.blue*256)+rgb.green)*256)+rgb.red
end;

As you can see it works by using 256 because the rbg values are 0-255.


program New;
type rgbcolor =record
red,green,blue:integer;
end;
var
color:integer;
color2:rgbcolor;
//---------Setup--------
const
color=5200980;



function color2rgb(color:integer):rgbcolor;
begin
result.red:=(color mod 256);
result.green:=((color/256) mod 256);
result.blue:=((color/256) / 256);
end;

function rgb2color(rgb:rgbcolor):integer;
begin
result:=(((rgb.blue*256)+rgb.green)*256)+rgb.red
end;


begin
writeln('----------------');
writeln(inttostr(color));
writeln(' ');

color2:=color2rgb(color)
writeln(inttostr(color2.red));
writeln(inttostr(color2.green));
writeln(inttostr(color2.blue));
end.
I wrote this to try and find the pattern (or at least range) in the color changes of a certain rock after switching worlds. You put in a color, say 5200980 and it outputs
—————-
5200980

84
92
79

I did this a few times to get a range for the grey rocks RGB values. I then put these ranges into the following script that uses Yakman's color displaying code. Notice how the colors are similiar when you change the RGB values in this script, but range when you change the SCAR value, like in Yakman's.
program New;
type rgbcolor =record
red,green,blue:integer;
end;
var
color,x,y,z,{x1,y1,z1,x2,y2,z2,}square,buffer:integer;
{waitforme:boolean; }
color1:rgbcolor;
//---------SETUP------------
const
//should I wait for you to press ctrl
//after showing the number of colors
//before displaying them?
waitformetotal=true;
//Should I wait for you to press ctrl
//before displaying each color?
waitforme=false;
x1=63;{red min} x2=97;{red max}
y1=75;{green min} y2=92;{green max}
z1=61;{blue min} z2=83;{blue max}







function rgb2color(rgb:rgbcolor):integer;
begin
result:=(((rgb.blue*256)+rgb.green)*256)+rgb.red
end;

begin

{waitforme:=false;

x1:=63; //red start
y1:=75; //green start
z1:=61; //blue start
x2:=97; //red end
y2:=81; //green end
z2:=83; //blue end
}
x:=x1-1;
y:=y1-1;
z:=z1-1;
writeln('there will be '+inttostr((x2-x1)*(y2-y1)*(z2-z1))+' colors');
if waitformetotal then
begin
repeat
wait(10);
until isfunctionkeydown(1);
end;
cleardebug;
square:=bitmapfromstring(50,50,'');

displaydebugimgwindow(100,100);
buffer:=bitmapfromstring(100,100,'') ;
repeat
x:=x+1;
y:=y1;
repeat
y:=y+1;
z:=z1;
repeat
z:=z+1;
//writeln(inttostr(x)+' '+inttostr(y)+' '+inttostr(z));
color1.red:=x;
color1.green:=y;
color1.blue:=z;
color:=rgb2color(color1);
writeln(inttostr(color)+' '+inttostr(x)+' '+inttostr(y)+' '+inttostr(z));
fastdrawclear(square,color)
fastdrawclear(buffer,0)
fastdrawtransparent(25,25,square,buffer)
safedrawbitmap(buffer,getdebugcanvas,0,0)
status('Color = '+inttostr(color))
if waitforme then
begin
repeat
wait(10);
until isfunctionkeydown(1);
end;
until z=z2;
until y=y2;
until x=x2;
end.

So, if you want to find similar colors, you need to change the RGB values.

So far, my experiments with finding a pattern in the color of a certain rock (to see which rock go to srl member scripts>fighters> WT Fakawi's Guard fighter> look at his zoomed in screen shot) show that there is no pattern in the SCAR color nor the RGB colors (that I can see with my small sample size) but there is a range. It took the lowest and highest RGB values, found the RGB ranges, multiplied those 3, and found that the range of greys so far is over 12 thousand, and that's from only 4 colors. The range of SCAR colors for these 4 is about 1.2mil, and includes all sorts of colors.

I started this because I wanted to make a procedure to auto color the color of the rock, and shape recognition didn't work because it changed and there were similiar shapes, neither did find a color that appeared a certain number (or within a range) of times. So I thought what I knew the range of colors it could be, and have the script go through them til it found 1. However, that's looking less likely with 12 thousand creeping up. It's interesting to investigate anyway though.

Congrats for reading this far.

BenLand100

2006-10-30 20:04:29

I'm sorry, but this is a speciality of mine, unlike spelling ;)
R:= (RGB and $ff0000) shr 16;
G:= (RGB and $00ff00) shr 8;
B:= (RGB and $0000ff);
RGB:= (R shl 16) or (B shl 8) or G;
yea, that's pascal…

weibs

2006-10-30 21:17:57

Wow, I didn't understand that at all, lol.

BenLand100

2006-10-31 23:20:27

From: BenLand100
I'm sorry, but this is a speciality of mine, unlike spelling ;)
R:= (RGB and $ff0000) shr 16;
G:= (RGB and $00ff00) shr 8;
B:= (RGB and $0000ff);
RGB:= (R shl 16) or (B shl 8) or G;
yea, that's pascal…

To be more (by more I mean much more then needed) specific a SCAR color, like any RGB color, is a nifty 24 bit value containing the red blue and green color values. Note the following (colored!) diagram:


11111111 11111111 11111111

Now, after meditating on that for a while you may see that the first 8 bits are red, the second 8 bits are green and the last 8 bits are blue. ;) As you know, the value 16777215 (FFFFFF in hex), is white. Now the previous diagram was the bit values for the color white. Lets look at the values for red, blue, and green colors.

11111111 00000000 00000000 = 16711680 = FF0000
00000000 11111111 00000000 = 65280 = 00FF00
00000000 00000000 11111111= 255 = 0000FF

Houston, we see a pattern! So, now that we see the positions of the three color values in the RGB color, we need to extract them. How do we do this? With bitwise logic of course! Note the following chart:

Pascal: and or shr shl
Java/C: & | >> <<

What do these things do? Thats what I'm here for. ;) Our friend and, otherwise known as the bit mask operator, does exactly what both its names mean, if the value of both input bits is 1 then the output is 1 otherwise 0, otherwise stated as low forces low. How does this make a bit mask? Note the following diagrams:

1 and 1 = 1
0 and 1 = 0
1 and 0 = 0
0 and 0 = 0

10101010 10101010 10101010 and 11111111 00000000 00000000 = 10101010 0000000000000000

You should see that the mask wanted only the first 8 bits and wanted to discard the last 16, also, you should see why that worked the way it did. Now for the or, or the combining operator. If there is a 1 in either bits the output is 1, or high forces high. How does this combine you ask? Note the following diagrams:

1 or 1 = 1
0 or 1 = 1
1 or 0 = 1
0 or 0 = 0

10101010 0000000000000000 and 00000000 1010101010101010 = 10101010 1010101010101010

This one might be a little harder to understand but you'll get the idea soon enough. Now, you may have noticed that I have been avoiding the bit shifts, but they are not that bad. ;) There are in fact two of them, shift left (shl) and shift right (shr). Each will move the bits in the first value the number of bits to the left or right specified. Note the following diagrams:

00000000 11111111 00000000 shl 1 = 00000001 11111110 00000000
00000000 11111111 00000000 shr 1 = 00000000 01111111 10000000

00000000 11111111 shl 2 =
00000011 11111100
00000000 11111111 shr 2 = 00000000 00111111

Notice how the zeros fill in when its moved to the left and how the bits dissappear when it is moved to far to the right, this is normal and okay. So, how does all this newfound knowledge help you with RGB colors, simple! Consult the diagam:

R:= (RGB and $ff0000) shr 16;

(11001100 10101010 11100010 and 11111111 00000000 00000000) = 11001100 00000000 00000000
11001100 00000000 00000000 shr 16 = 11001100

G:= (RGB and $00ff00) shr 8;

(11001100 10101010 11100010 and 00000000 11111111 00000000) = 00000000 10101010 00000000
00000000 10101010 00000000 shr 8 = 10101010

B:= (RGB and $0000ff) shr 0

(1100110010101010 11100010 and 00000000 00000000 11111111) = 00000000 00000000 11100010
00000000 00000000 11100010 shr 0 = 11100010

Note that a shr 0 does nothing except make all the diagrams look the same. ;) So, you have your individual values, and thats all dandy but what about putting them together again? (no this is not humpty dumpty :p) Consult the diagram:

RGB:= (R shl 16) or (G shl 8) or (B shl 0);

11001100 shl 16 = 11001100 00000000 00000000
10101010 shl 8 = 0000000010101010 00000000
11100010 shl 0 = 0000000000000000 11100010
11001100 00000000 00000000 or 00000000 10101010 00000000 = 11001100 10101010 00000000
11001100 10101010 00000000or 00000000 00000000 11100010 = 11001100 11100010 10101010

Note that a shl 0 does nothing also. ;) So, now you see the bitwise brilliance of RGB

Edit: The more I look at this, i think somone should put it in a tutorial ;)

Boreas

2006-11-01 00:02:33

Hmm I thought it was BBGGRR? Reversed for changed frequency.

Also why go to all that trouble? It is simply converting to and from hex, which is just means a base of 16 instead of 10, (256 and 100 respectively if you talking 2 at a time). So why not just stick to simple math?


Edit: Yea it is reversed. I just tried your conversion thing. It got blue and red mixed up. Just stick with my method. Here's how to test:

Open Paint.
Go to Color>Edit Colors
Click a white box at the bottom.
Click define custom colors
click anywhere on the box
move the slider down so that Red Green and Blue are all different. Not both the same like in your example.
click add to custom colors
Open Scar
Copy this in
program New;
const rgb=8544432;
var r,g,b:integer;

begin
R:= (RGB and $ff0000) shr 16;
G:= (RGB and $00ff00) shr 8;
B:= (RGB and $0000ff);
writeln(inttostr(r));
writeln(inttostr(g));
writeln(inttostr(b));


end.
Color pick the custom color you made.
Copy that into the const
Click run
Compare the output to the Edit Colors screen on paint


Now try with this script
program New;
type rgbcolor =record
red,green,blue:integer;
end;
var
color2:rgbcolor;
//---------Setup--------
const
color=8544432;
//-------------------


function color2rgb(color:integer):rgbcolor;
begin
result.red:=(color mod 256);
result.green:=((color/256) mod 256);
result.blue:=((color/256) / 256);
end;

function rgb2color(rgb:rgbcolor):integer;
begin
result:=(((rgb.blue*256)+rgb.green)*256)+rgb.red
end;


begin
writeln('----------------');
writeln(inttostr(color));
writeln(' ');

color2:=color2rgb(color)
writeln(inttostr(color2.red));
writeln(inttostr(color2.green));
writeln(inttostr(color2.blue));
writeln(' ');
end.

BenLand100

2006-11-01 17:53:42

From: Boreas
Hmm I thought it was BBGGRR? Reversed for changed frequency.

Also why go to all that trouble? It is simply converting to and from hex, which is just means a base of 16 instead of 10, (256 and 100 respectively if you talking 2 at a time). So why not just stick to simple math?


My mistake, I'm mostly a java guy anyway and never realised that scar was different from the normal RGB color model. ;) Also, why go through all that trouble is a good question that I neglected to answer. Bitwise operators are faster then numerical operators. This may not be as noticable on some computers, and on others it might be more pronounced, but, as scar uses and interpreter for its pascal, the difference will be less pronounced then on any other real programming language. Note the following program: ;)
procedure split1(color: integer);
var
R, G, B: integer;
begin
B:= color mod 256;
G:= (color / 256) mod 256;
R:= (color / 256) / 256;
end;

procedure split2(color: integer);
var
R, G, B: integer;
begin
B:= (color and $ff0000) shr 16;
G:= (color and $00ff00) shr 8;
R:= (color and $0000ff);
end;

// Tests time difference on getting the color values of an
// 800 x 600 pixel image using numerical and bitwise operators
var
MARK,i:integer;
begin
MARK:= getSystemTime();
for i:= 1 to 480000 do
split1(3302655);
writeLn(intToStr(getSystemTime - MARK));
MARK:= getSystemTime();
for i:= 1 to 480000 do
split2(3302655);
writeLn(intToStr(getSystemTime - MARK));
end.

weibs

2006-11-01 18:21:07

Thanks ben, I didn't mean for you to have to explain it, but I have a question. I get all of what you said until you explained the R := (RGB and $ff0000) shr 16; and the others. I don't get why shr 16; is needed. Wouldn't that just shift the red value 16 places so that it would be 00000000 00000000 red value? And wouldn't that put it in the blue area?

Thanks again for explaining this.

EDIT: I think I get it, but first, do the 0's before the red value dissapear? Because if they do, I get it.

Boreas

2006-11-01 21:22:40

Oh ok, so what uses the normal model?


EDIT: Bitwise is slower than numerical. See next 2 posts.

Good point, I never thought of that. I got a 297ms difference on the test.

Bitwise is 0.00061875 milliseconds per color [STRIKE]faster[/STRIKE]EDIT: slower than numerical with P4 2.8GHz 512MB RAM if anyones interested.

tarajunky

2006-11-01 21:59:58

From: Boreas
Oh ok, so what uses the normal model?

Good point, I never thought of that. I got a 297ms difference on the test.

Bitwise is 0.00061875 milliseconds per color faster than numerical with P4 2.8GHz 512MB RAM if anyones interested.


It's strange, but bitwise was consistently SLOWER on my machine.

Successfully compiled
Successfully compiled
4000
4047
Successfully executed
Successfully compiled
3953
3985
Successfully executed
Successfully compiled
3953
4203
Successfully executed

Boreas

2006-11-01 22:05:27

OOPS. You're right, bitwise is slower for me too. I assumed the lower number was bitwise. I'll stick with the mod 256 method.

Successfully compiled
3891
4484
Successfully executed
Successfully compiled
3828
4000
Successfully executed
Successfully compiled
3860
3906
Successfully executed

BenLand100

2006-11-01 22:24:27

Odd. But no matter, interpreted languages are not the same as compiled languages. There is a good chance that, depending on what else is running on your machine you'll get different results each time. ;)

Edit:
Successfully compiled
3188
2937
Successfully executed
Successfully compiled
3438
3344
Successfully executed
Successfully compiled
3360
3609
Successfully executed
Successfully compiled
3218
3125
Successfully executed
Successfully compiled
3391
3188
Successfully executed
Successfully compiled
3219
3437
Successfully executed
Successfully compiled
3266
3391
Successfully executed
Successfully compiled
3375
3641
Successfully executed
Successfully compiled
3218
3188
Successfully executed
Successfully compiled
3203
3328
Successfully executed

weibs

2006-11-01 22:29:13

I got faster times with bens method, but I still have one question:

From: weibs
Thanks ben, I didn't mean for you to have to explain it, but I have a question. I get all of what you said until you explained the R := (RGB and $ff0000) shr 16; and the others. I don't get why shr 16; is needed. Wouldn't that just shift the red value 16 places so that it would be 00000000 00000000 red value? And wouldn't that put it in the blue area?

Thanks again for explaining this.

EDIT: I think I get it, but first, do the 0's before the red value dissapear? Because if they do, I get it.


So do the 0's dissappear if they're on the left or something?

BenLand100

2006-11-01 22:42:20

From: weibs
I got faster times with bens method, but I still have one question:

So do the 0's dissappear if they're on the left or something?


You have to remember that the number (in base 10 for ease of viewing) 00013567 is the same as 13567, just without the leading zeros. Same goes for binary, unsigned binary anyway… Anywho as a folowup as why use the bitwise method over the numerical method. say you have any color value and you wanted blue to be its full value (in scar color)…

RGB:= RGB or 0xFF0000;
Or say you only want half the green…

RGB:= (RGB and $FF00FF) or (((RGB and $FF00) shr 9) shl 8)
The biggest advantage to the way of bitwise is you can modify parts of a color without having to remake the color with the red, green, and blue values.
BTW: shl is multiplying by 2, and shr is dividing by 2 (no remainder). not that that is what they do, but it is a side effect of moving bits around

Boreas

2006-11-01 22:56:37

I put a repeat in the script and add 'num' and 'bit' to the output and ran it while I was doing stuff.


Successfully compiled
num3906
bit5516
num5656
bit5672
num5640
bit5485
num5578
bit5484
num5594
bit5422
num5781
bit5828
num5844
bit5344
num5875
bit4281
num3922
bit3750
num3828
bit3844
num3906
bit3735
num4906
bit3734
num4110
bit4203
num9235
bit3969
num4593
bit3922
num4313
bit3906
num3984
bit3828
num4235
bit3844
num4297
bit4422
num4250
bit7234
num5797
bit6281
num5313
bit5000
num5297
bit5062
num5282
bit5125
num5218
bit5110
num5172
bit5015
num5125
bit5391
num5312
bit5063
num5328
bit4922
num5250
bit5172
num5250
bit5203
num5297
bit5109
num5406
bit5094
num5390
bit5063
num5328
bit4953
num5219
bit4781
num5188
bit4796
num5110
bit4984
num5172
bit3625
Successfully executed



Either way it's not a big difference unless you're doing a lot.

ruler

2006-11-02 19:25:53


public RGB(int color, int type) {
if (type == COLOR_TYPE_AWT) {
r = (short)((color >> 16) & 0xff);
g = (short)((color >> 8) & 0xff);
b = (short)((color) & 0xff);
} else if (type == COLOR_TYPE_SCAR) {
r = (short)((color) & 0xff);
g = (short)((color >> 8) & 0xff);
b = (short)((color >> 16) & 0xff);
}
}
public int toColor(int type) {
if (type == COLOR_TYPE_AWT) {
return (r * 65536) + (g * 256) + b;
} else if (type == COLOR_TYPE_SCAR) {
return r + (g * 256) + (b * 65536);
}
return -1;
}