Draw the image in a memory device context in which the CBitmap object is selected.
Like in next example:

 

Code:
using namespace Gdiplus;
Image* pImage = Image::FromFile(L"c:\\test.gif");
Status status = pImage->GetLastStatus();
if(Ok == status)
{
   CDC dc;
   dc.CreateCompatibleDC(NULL);
   CBitmap bitmap;
   bitmap.CreateCompatibleBitmap(&dc, pImage->GetWidth(), pImage->GetHeight());
   CBitmap* pbmpOld = dc.SelectObject(&bitmap);

   Graphics graphics(dc.m_hDC);
   status = graphics.GetLastStatus();
   if(Ok == status)
   {
      graphics.DrawImage(pImage, 0, 0);
      // enjoy of bitmap;
   }
   dc.SelectObject(pbmpOld);
}
Much more easier is if you have Bitmap (Bitmap is derived from Image) that has GetHBITMAP method:
Code:
using namespace Gdiplus;
Bitmap* pBitmap = Bitmap::FromFile(L"c:\\test.gif");
Status status = pBitmap->GetLastStatus();
if(Ok == status)
{
   HBITMAP hBitmap = NULL;
   status = pBitmap->GetHBITMAP(Color(0,0,0), &hBitmap);
   if(Ok == status)
   {
      CBitmap bitmap;
      bitmap.Attach(hBitmap);
      // enjoy of bitmap;
   }
}

相关文章:

  • 2021-07-04
  • 2022-12-23
  • 2022-12-23
  • 2021-09-14
  • 2022-01-15
  • 2021-12-13
  • 2021-09-26
  • 2021-06-05
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-03-02
  • 2021-11-29
  • 2021-07-10
  • 2021-11-27
相关资源
相似解决方案