从buffer读取一位
//pButter :指定buffer
//nstart:指定位置
//nEnd:返回结束位置
//retByte:返回读取结果值
void ReadOneBit(byte* pButter, int nstart,int& nEnd, byte& retByte)
{
byte Data = pBuffer[nstart/8];
Data = Data<<nstart%8;
retByte = Data >>7;
nEnd = nstart+1;
}
在Buffer里写入Bit
//pButter :指定buffer
//btData:要写入的值
//nstart:指定位置
//nEnd:返回结束位置
void WriteOneBit(byte* pButter,byte btData, int nstart,int& nEnd)
{
int nSet = nstart/8;
byte c=pButter[nSet];
switch(btData)
{
case 1:
c |= (1 << (7 - nstart%8);
break;
case 0:
c &= (~(1<<(7-nstart%8)));
break;
default:
return;
}
pBuffer[nSet] = c;
nEnd=nstart +1;
}