Archived

This topic is now archived and is closed to further replies.

Color channels and bit shifting

This topic is 5045 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi everyone, I have yet again another simple question. I am having a little trouble with getting the individual color channels from windows COLORREF. I have done this kind of thing with java before but I am not quite sure what I am doing wrong here. COLORREF is setup in this format: RED = 0x000000FF; GREEN = 0x0000FF00; BLUE = 0x00FF0000; I am using these functions to strip the color channels:
int particle::getR(void){
		
	return (this->color & 0xFF);
}

int particle::getB(void){
	
	return ((this->color & 0xFF0000)>>16);
}

int particle::getG(void){

	return ((this->color & 0xFF00)>>8);
}
the color variable is in the same format as the colors define above. From the articles I''ve googled and the posted here on gamedev, it should work as far as I can tell. But it doesn''t seem to strip te channels correctly and most colors seem to be coming up as white or red. Any hlep would be greatly appreciated. Andy "And then 2 men appeared... Men in dark suits.. with dark soulless eyes. Men like this could have come from only one place..
The bank."

Share this post


Link to post
Share on other sites
Hey Thanks for the reply. It turns out my problem was in the render and not in stripping the color channels. BTW I tried doing the masking and shifting like you suggested and it would turn a white color yellw(after I fix the reder problem).

Anyway thanks again.

Andy


"And then 2 men appeared... Men in dark suits.. with dark soulless eyes. Men like this could have come from only one place..
The bank."

Share this post


Link to post
Share on other sites