Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Win32 bitmap color to grayscale

Tags:

c++

winapi

i am writing a program that opens, rotates, scales,invert color,converts to grayscale and save bitmap (.bmp) But i dont seem to get the the converting to greyscale(ie black and white) working every other code works perfectly...

the code for my color inversion is below...

 case 3:
{
    hdc=GetDC(hWnd);
    GetClientRect(hWnd,&rt);
    BitBlt(hdc,0,0,rt.right,rt.bottom,hdc,0,0,NOTSRCCOPY);
    ReleaseDC(NULL,hdc);
}

this seem to work but getting the DC and trying to change it to grey scale isn't working using BitBlt... I would like to get an idea on how to get the DC and convert it to grey-scale... winapi thanks...

like image 265
Alex Avatar asked Jan 19 '26 23:01

Alex


1 Answers

Raymond Chen gives a complete example of using the color mapper in GDI to convert a color image to grayscale using BitBlt.

like image 59
Adrian McCarthy Avatar answered Jan 22 '26 13:01

Adrian McCarthy