April 12th, 2011, 03:55 AM
Difference between SetDIBitsToDevice() and BitBlt()?
I wanted to display a bitmap data within a Picture Control. For that, I implemented the visualization on the one hand by means of <b>setDIBitsToDevice()</b>, where the image data in array is displayed usind the device context (DV) of the picture control directly, and on the other hand by creating a second device context, assigning a created DIbitmap to it and transfering the data from second DC to the first one:
Both methods are working fine, but I wonder why there are two methods for the same purpose? I watched the CPU load for each method to see, whether they differ in performance. However, they don't differ.
// create a mirror device context associated with the target device context
HDC hdcCreated = ::CreateCompatibleDC(hdc);
// create a bitmap, which will be selected together with the defined device context
HBITMAP bmCreated = ::CreateDIBitmap(hdc, (BITMAPINFOHEADER*)&(BmInfo.bmiHeader), CBM_INIT , (VOID*)myImageArray, &BmInfo, DIB_RGB_COLORS );
// connect the bitmap with the mirror device context
HBITMAP hBmOld = (HBITMAP) ::SelectObject(hdcCreated, bmCreated);
// transfer the bitmap data from the mirror device context to the target DC
//::BitBlt(hdc,0,0, m_nSizeX, m_nSizeY, hdcCreated, 0, 0, SRCCOPY);
// delete created bitmaps and DC, if not used anymore
Can you tell me please, in which cases should the first method and in which the second method be used?
Last edited by vanselm; May 5th, 2011 at 10:41 AM.
Tags for this Thread
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!