C++ converting from char to integer
Hey, easy question...
I am reading a pnm image file where each rgb value is 3 single bytes. I'm reading it into a char array. How can I then get the decimal (unsigned) value? For example, if the color is RGB(224,223,224), how can I get those into an unsigned variable as such? That is, I don't want RGB(-32,-33,-32).
I want to be able to do a comparison to see if each is within a range of values. So, for a given pixel, I'm checking if the red value is less than 225 and greater than 235 as an example. I want to be able to do
char r = 224; // stored in 8-bits = -32
if (r > 220 && r < 235)
{
// the above evauates to false because -32 is NOT > 220
}
I'm sure it's a simple newbie question.
Thanks,
Micah
|