I am currently working on a dialog application in which I want to
display a bitmap which I manipulate based on data in a file.
I can display the bitmap by putting the following code, copied from
CodeGuru, in the OnPaint function:
/////////////////////////////
HBITMAP hBmp = (HBITMAP)::LoadImage(NULL, "filename.bmp",
IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE/LR_CREATEDIBSECTION);
bmp.Attach(hBmp); // CBitmap bmp was declared as a member function in
the class view
CClientDC dc(this);
CDC bmDC;
bmDC.CreateCompatibleDC(&dc);
CBitmap *pOldbmp = bmDC.SelectObject(&bmp);
BITMAP bi;
bmp.GetBitmap(&bi);
dc.BitBlt(0,0,bi.bmWidth, bi.bmHeight, &bmDC, 0,0, SRCCOPY);
bmDC.SelectObject(pOldbmp);
/////////////////////////////////////////////////////
I would like to edit the values of the bitmap. Within the OnPaint
function, I can do so using bmp.SetBitmapBits.
But I would like to do this editing in another member function. But I'm
missing something because when I invoke the SetBitmapBits in another
function, nothing changes.
Thanks in advance,