The conversion is as easy as already answered but you need to take care when making it to a COLORREF again. You need the same byte order and the same color depth.
When you mismatch it the colors are weirdly changed.
To better learn about working with images you should read the
CXimage article and dig through the sample code. You have to love it. ;-)