PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

GetPixel returns bad value

Anyone have a good example of extracting pixel colors from surface, following code give me values but they don't match.

COLORREF c;
int n;

surface.GetPixel( x, y, &c);

n = GetBValue( c); // Extracting red value;

I get 0 from n when it's zero, but then I get 96 or 104 for all the other colors I use. Is GetBValue mixing up the bit order maybe?

/nB
Ummm.. ?

n = GetBValue( c); // Extracting red value;


Red value? Blue value?
I really didn't understand...
Sorry suppose to be GetRValue, this function suppose to extract the Red value from a 32bit RGB (Colorref).

Is there an easier way to get the exact value for red, green and blue?

I'm looking for the red value because I've a colorcoded mask that corresponds to possible buttons to press.

Thanks.

/nB
Seems I found what the problem is, the surface after loaded from the resource are converted to 16bits.

Is there anyway way to keep a loaded resource as a 24bit surface. This is not used for blitting so performance isn't an issue in this case.

/nB