Hi,
given an array of u16 that has the 64 colors for the 4 palettes, I wanted to read the R, G, B components of each color.
I thought that PRed=palette&&VDPPALETTE_REDMASK; would work, for instance, to read the RED component.
But seems I am wrong... :/
Any suggestion?
Getting the R, G, B components of a palette color
Moderator: Stef
-
- Interested
- Posts: 10
- Joined: Fri Mar 20, 2020 6:59 pm
Re: Getting the R, G, B components of a palette color
Hint: && is the "logical and" operator. It produces a true/false value.
Re: Getting the R, G, B components of a palette color
.
Last edited by Miquel on Mon Jan 18, 2021 6:23 pm, edited 1 time in total.
HELP. Spanish TVs are brain washing people to be hostile to me.
Re: Getting the R, G, B components of a palette color
It's 0000BBB0GGG0RRR0 actually
blue = (color >> 9) & 7;
green = (color >> 5) & 7;
red = (color >> 1) & 7;
blue = (color >> 9) & 7;
green = (color >> 5) & 7;
red = (color >> 1) & 7;
Sik is pronounced as "seek", not as "sick".
-
- Interested
- Posts: 10
- Joined: Fri Mar 20, 2020 6:59 pm
Re: Getting the R, G, B components of a palette color
Thanks alot!
This way was solved.
BTW I made a mistake in putting &&, mistake that I corrected but the real problem, as you guys hinted, was in the bit operation.
Adding:
PRed >>= 1;
PGreen >>= 5;
PBlue >>= 9;
After the "&" masking solved the problem.
Thanks again for the prompt feedback!
This way was solved.
BTW I made a mistake in putting &&, mistake that I corrected but the real problem, as you guys hinted, was in the bit operation.
Adding:
PRed >>= 1;
PGreen >>= 5;
PBlue >>= 9;
After the "&" masking solved the problem.
Thanks again for the prompt feedback!
Re: Getting the R, G, B components of a palette color
(Sorry but people is throwing objects to my house, firecrackers it seems by the amount of damage: deleting messages)
Last edited by Miquel on Mon Jan 18, 2021 6:25 pm, edited 1 time in total.
HELP. Spanish TVs are brain washing people to be hostile to me.
-
- Interested
- Posts: 10
- Joined: Fri Mar 20, 2020 6:59 pm