============================================================================= BitmapGrayScale() Gray scale color channel only
| 301 | // Gray scale color channel only |
| 302 | // |
| 303 | BOOL BitmapGrayScale ( HBITMAP hbmp ) |
| 304 | { |
| 305 | BITMAP bmp; |
| 306 | if ( GetObject ( hbmp, sizeof ( BITMAP ), &bmp ) ) { |
| 307 | if ( bmp.bmBitsPixel == 32 ) { |
| 308 | int x, y; |
| 309 | RGBQUAD *prgba = bmp.bmBits; |
| 310 | for ( y = 0; y < bmp.bmHeight; y++ ) { |
| 311 | for ( x = 0; x < bmp.bmWidth; x++ ) { |
| 312 | prgba[x].rgbRed = prgba[x].rgbGreen = prgba[x].rgbBlue = |
| 313 | ( ( ( BYTE ) ( ( prgba[x].rgbRed * 38 + prgba[x].rgbGreen * 75 + prgba[x].rgbBlue * 15 ) >> 7 ) * 0x80 ) + ( 0xD0 * ( 255 - 0x80 ) ) ) >> 8; |
| 314 | } |
| 315 | prgba = ( RGBQUAD * ) ( ( LPBYTE ) prgba + bmp.bmWidthBytes ); |
| 316 | } |
| 317 | return TRUE; |
| 318 | } |
| 319 | } |
| 320 | return FALSE; |
| 321 | } |
| 322 | |
| 323 | |
| 324 | //============================================================================= |