Author Topic: Visual C++ function for displaying Bitmap using CDC  (Read 1038 times)

kathir

  • Administrator
  • Sr. Member
  • *****
  • Posts: 283
Visual C++ function for displaying Bitmap using CDC
« on: February 21, 2012, 12:41:02 pm »
Here is the Visual C++ function for displaying Bitmap using CDC:

Code:
//Source Code Listing


void DisplayImage(CDC *pDC, const char *filename, int left, int top, int right, int bottom)
   {
      int height = bottom - top;
      int width = right - left; 

      CBitmap bitmap;
      bitmap.m_hObject=(HBITMAP)::LoadImage(NULL, filename, IMAGE_BITMAP, width, height, LR_LOADFROMFILE);

      CDC *bitmapDC = new CDC();
      bitmapDC->CreateCompatibleDC(pDC);

      bitmapDC->SelectObject(bitmap);
      pDC->BitBlt(left, top, right, top + 20,bitmapDC,0,0,SRCCOPY);

      delete bitmapDC;

   }




 


Disclaimer: This web site is for educational and informational purposes only. Click here to read the Disclaimer.
Content copyright 2010-2014. Kathiresan. All rights reserved.
This page is using SMF version 2.0.1