SRL Archive - Bugs

simba returns wrong color?


KingKong

2011-12-19 23:13:35

I don't know if its done on purpose but simba(and scar) return the wrong integer color values. Eg: I pick a color from the rs screen and the pixel has rgb values of (123, 122, 121). The integer color value of this pixel should be 8092281(hex value of 7B7A79), but simba(and scar) return 7961211(rgb value of 121, 122, 123. Which means the red and blue values are swapped).

Brandon

2011-12-20 00:44:10

From: KingKong
I don't know if its done on purpose but simba(and scar) return the wrong integer color values. Eg: I pick a color from the rs screen and the pixel has rgb values of (123, 122, 121). The integer color value of this pixel should be 8092281(hex value of 7B7A79), but simba(and scar) return 7961211(rgb value of 121, 122, 123. Which means the red and blue values are swapped).



Simba Code:

program new;

begin
writeln(GetColor(1109, 164));
writeln(RGBToColor(145, 146, 217));
end.
Results:
[BANANA]
Compiled successfully in 16 ms.
14258833
14258833
Successfully executed.
[/BANANA]



C++ Code:


#include <iostream>
#include <windows.h>

using namespace std;

COLORREF centerColor;
POINT loc;

int main()
{
HDC hdc = GetDC(GetDesktopWindow()) ;
loc.x = 1109;
loc.y = 164;
centerColor = GetPixel(hdc, loc.x, loc.y);
cout<<centerColor;
ReleaseDC(GetDesktopWindow(), hdc);
}
Results:
[BANANA]
14258833
[/BANANA]


Seems to be right to me :S Are you sure your pixel isn't changing ever so slightly because after all it is runescape/jagex..

KingKong

2011-12-20 01:37:46

go here and check the answer:
http://drpeterjones.com/colorcalc/

KingKong

2012-01-06 07:32:42

bump

Wizzup?

2012-01-06 07:33:28

From: KingKong
bump


Has it occurred to you that site may be wrong? :)

E: What ggzz said.

nielsie95

2012-01-06 07:47:11

Looks like the hex is wrong at that site.

EDIT: Not wrong, but a hex triplet. So for each colour it has two characters. clRed (255) should be $FF, but it says $FF0000 (which actually is blue). I guess you could say red and blue are switched, as with the normal hex notation the least significant part is at the right. That means red is right and blue is left, but with the CSS notation it's hexR hexG hexB glued together.

KingKong

2012-01-06 08:28:34

ah ok. but for future reference whats the way to convert rgb to color? r x 256^3 + g x 256^2+ b? or swap r and b?

nielsie95

2012-01-06 08:40:37

Yes, swap r and b: R + (G shl 8) + (B shl 16). Shl (shift left) multiplies by 2^n (in this case 256 and 256*256).

Daniel

2012-01-06 10:35:15

From: nielsie95
Yes, swap r and b: R + (G shl 8) + (B shl 16). Shl (shift left) multiplies by 2^n (in this case 256 and 256*256).


Or use RGBToColor conversion methods in Simba.. :p