If I load a Bitmap from a file and I have Cbitmap and HBITMAP how is
possible to use GetBitmapBits and SetBitmapBits to modify the image
inside the memory?

BITMAP m_Bitmap; // Struct to hold info about the bitmap
HBITMAP m_hBitmap; // Handle of the bitmap

// Load the image
m_hBitmap = (HBITMAP)LoadImage(GetModuleHandle(NULL), "Image.bmp",
if (m_hBitmap == NULL)
MessageBox("Error loading bitmap");
//Get information about the bitmap..
GetObject(m_hBitmap, sizeof(m_Bitmap), &m_Bitmap); // Get info about
the bitmap
// Put the bitmap into a memory device context
CPaintDC dc(this);
//get a memory dc object
CDC dcMem;
//create a compatible dc
dcMem.CreateCompatibleDC(&dc); // Select the bitmap into the in-memory
//Select the bitmap into the dc
CBitmap* pOldBitmap =
dcMem.SelectObject(CBitmap::FromHandle(m_hBitmap)) ;

I've tried to use GetBitmapBits and SetBitmapBits but I have a lot of

If you know a link about this question it's ok too. With a search
engine I've seen a lot of code but nothing that can solve my question.