VC++ - Save modified image into bmp file.

I need to save a modified image which is being displayed in a window. I am  using VC++ 6.0.

The image is loaded from a bmp file and displayed in a child window. Using the device context, I inserted some text into the image.

My problem is how do I save this image together with the text shown in this child window into a bmp file?

Or is there any way that I can write the text straight into the image bits?

I prefer the solution to the first question.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

  CDC dcStretchMem;
      if(! dcStretchMem.CreateCompatibleDC(&m_dcMem))
            MessageBox("Can't Create Compatible DC","Message",MB_OK);
      CBitmap bmpPrint;
      if(! bmpPrint.CreateCompatibleBitmap(&m_dcMem,nWidth,nHeight))
            MessageBox("Can't Create Compatible Bitmap","Message",MB_OK);
      CBitmap* pbmpOld = dcStretchMem.SelectObject(&bmpPrint);
            MessageBox("Can't Select Bitmap","Message",MB_OK);
      if(! dcStretchMem.StretchBlt(0,0,nWidth,nHeight,&m_dcMem,
            MessageBox("Can't Stretch Bitmap","Message",MB_OK);
      BOOL bRetVal = pDC->BitBlt(nStartX,nStartY,nWidth,nHeight,&dcStretchMem,


You create a Memory Device context and create a compatible bitmap. Then Call StretchBlt or BitBlt to that Device then store the Bitmap in File.
Use GetBitmapBits for that.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.