I read up on this at MSDN and im confused about how to use it. Ive gotten every other function I need to get a bitmap on the screen accept this one. Can you please explain to me how to use it?
HDC hdcDest, // handle to destination DC
int nXDest, // x-coord of destination upper-left corner
int nYDest, // y-coord of destination upper-left corner
int nWidth, // width of destination rectangle
int nHeight, // height of destination rectangle
HDC hdcSrc, // handle to source DC
int nXSrc, // x-coordinate of source upper-left corner
int nYSrc, // y-coordinate of source upper-left corner
DWORD dwRop // raster operation code
First off, BitBlt is simply a block transfer, you are simply copying a hunk of data from one area to another area, so if (simplifying device contexts) hdcSrc is a bitmap and hdcDest is a window, you copy your bitmap to your window.
hdcDest is where you want your bitmap to be drawn, for example on a window:
HDC hdc = GetDC ( hWnd ) ;
ReleaseDC ( hWnd, hdc ) ;
nXDest and nYDest is where on hdc you want your bitmap to be drawn, x and y (in pixels) with the topleft as the origin.
nWidth and nHeight are how wide and high you want your bitmap to be when drawn onto hdc, these will be your bitmap's width and height values.
hdcSrc is a dc for the bitmap you want to draw, for example:
HDC hdcMem = CreateCompatibleDC ( hdc );
HBITMAP hbmOld = SelectObject ( hdcMem, hTheBitmap );
nXSrc and nYSrc are the topleft x and y on hdcSrc you want to copy from to hdcDest, these will be 0 (assuming you want your whole image).
dwRop is kind of what you want to happen. For example you can or pictures and and pictures together, you probably want SRCCOPY, this simply copies hdcSrc to hdcDest.
Ok im still a bit confused on the hdcSrc
HBITMAP hmainbg = LoadBitmap(hmaininstance,"test.bmp");
HDC hmaindc = GetDC(hmainwnd);
in case you need more speed (for animations or if the user
is allowed to zoom in realtime) use DrawDibDraw instead:
this function belongs to Video for Windows.
all you got to do is change your bitmap data from top-down-RGB
to bottom-up-BGR and add the DrawDibOpen and DrawDibClose calls.
example wndproc could look like this:
hdib = DrawDibOpen();
HDC hdc = GetDC( hwnd );
DrawDibDraw( hdib, hdc, ... );
ReleaseDC( hwnd, hdc );
DrawDibClose( hdib );
DrawDib at MSDN: