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.

jophreyAsked:
Who is Participating?
 
basantConnect With a Mentor Commented:
  CDC dcStretchMem;
      if(! dcStretchMem.CreateCompatibleDC(&m_dcMem))
      {
            MessageBox("Can't Create Compatible DC","Message",MB_OK);
            return;
      }
      CBitmap bmpPrint;
      if(! bmpPrint.CreateCompatibleBitmap(&m_dcMem,nWidth,nHeight))
      {
            MessageBox("Can't Create Compatible Bitmap","Message",MB_OK);
            return;
      }
      CBitmap* pbmpOld = dcStretchMem.SelectObject(&bmpPrint);
      if(!pbmpOld)
      {
            MessageBox("Can't Select Bitmap","Message",MB_OK);
            return;
      }
      if(! dcStretchMem.StretchBlt(0,0,nWidth,nHeight,&m_dcMem,
                  0,0,nMaxX,nMaxY,SRCCOPY))
      {
            MessageBox("Can't Stretch Bitmap","Message",MB_OK);
            return;
      }
      BOOL bRetVal = pDC->BitBlt(nStartX,nStartY,nWidth,nHeight,&dcStretchMem,
                  0,0,SRCCOPY);

      dcStretchMem.SelectObject(pbmpOld);



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.
0
All Courses

From novice to tech pro — start learning today.