static int Shift(byte channel, uint mask)
{
int shifted = 0;
if (mask != 0)
{
shifted = channel;
// Shift colour to position of mask. This method moves the mask back towards 0 a number of times, and the channel colour the same number "up".
while ((mask & 0xFF) == 0)
{
mask >>= 8;
shifted <<= 8;
}
}
return shifted;
}
}