app/src/main/jni/ImageTool.cpp
int CImageTool::GetBlackPixelNum ( DSCC_BYTE *p, int wb, int hh, int left, int top, int w, int h )
{//It is not optimal, should use lut, lz, rz defined in Tools.cpp
    DSCC_BYTE mask[8] = {128, 64, 32, 16, 8, 4, 2, 1 } ;
    int sum = 0 ;

    for ( int i=0 ; i<h ; i++ )
    {
        DSCC_BYTE *tp = p+(hh-1-top-i)*wb + left/8 ;
        int k = left%8 ;
        for ( int j=0 ; j<w ; j++ )
        {
            if ( *tp & mask[k++] ) sum++ ;
            if ( k == 8 ) tp++, k=0 ;
        }
    }
    return sum ;
}
/*****************************************************************************
/*	Name:		GetBlackPixelNum
/*	Funcation:	Get the number of black pixels in an image block.
/*	Parameter:	p -- Pointer to the image data, DIB format
/*				wb -- Line size in bytes
/*				hh -- Image height
/*				left -- Left ordinate of the image block
/*				top -- Top ordinate of the image block
/*				w -- Width of the image block
/*				h -- Height of the image block
/*	Return:		Number of black pixels in an image block	
/*
/*****************************************************************************/
GetBlackPixelNum
Funcation:      Get the number of black pixels in an image block.
GetBlackPixelNum Funcation : Get the number of black pixels in an image block .
int CImageTool::GetBlackPixelNum ( DSCC_BYTE *p, int wb, int hh, int left, int top, int w, int h )
{
    DSCC_BYTE mask[8] = {128, 64, 32, 16, 8, 4, 2, 1 } ;
    int sum = 0 ;
    for ( int i=0 ; i<h ; i++ )
    {
        DSCC_BYTE *tp = p+(hh-1-top-i)*wb + left/8 ;
        int k = left%8 ;
        for ( int j=0 ; j<w ; j++ )
        {
            if ( *tp & mask[k++] ) sum++ ;
            if ( k == 8 ) tp++, k=0 ;
        }
    }
    return sum ;
}
int CImageTool :: GetBlackPixelNum ( DSCC_BYTE * p , int wb , int hh , int left , int top , int w , int h ) { DSCC_BYTE mask [ 8 ] = { 128 , 64 , 32 , 16 , 8 , 4 , 2 , 1 } ; int sum = 0 ; for ( int i = 0 ; i < h ; i ++ ) { DSCC_BYTE * tp = p + ( hh - 1 - top - i ) * wb + left / 8 ; int k = left % 8 ; for ( int j = 0 ; j < w ; j ++ ) { if ( * tp & mask [ k ++ ] ) sum ++ ; if ( k == 8 ) tp ++ , k = 0 ; } } return sum ; }
Name:           GetBlackPixelNum
Funcation:      Get the number of black pixels in an image block.
Name : GetBlackPixelNum Funcation : Get the number of black pixels in an image block .
//It is not optimal, should use lut, lz, rz defined in Tools.cpp