BYTE * TrueBMPto256( BYTE * pBmpBuf, int bmpWidth, int bmpHeight) //lineByte:实际宽度;
{
BYTE * ptempPixel = new BYTE[((bmpWidth+3)/4*4)*bmpHeight];
for ( int n = 0; n < bmpHeight ; n++ )
{
BYTE * temp_lpdib = pBmpBuf + n*((((bmpWidth * 8) + 31) & ~31) >> 3) ;
long I8BMPbuf = n*((bmpWidth+3)/4*4);
for( int m = 0; m < bmpWidth; m++)
{
int i_Color =int( *(temp_lpdib+0)* 299 + *(temp_lpdib+1)* 587 + *(temp_lpdib+2)* 114 ) / 1000;
ptempPixel[I8BMPbuf++ ] = i_Color;
temp_lpdib = temp_lpdib + 3 ;
}
}
return ptempPixel ;
}