Click to See Complete Forum and Search --> : Bit-blt- Source coordinates, relativitey of units


Josef_Stalin
July 17th, 2005, 12:36 PM
BOOL BitBlt(
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

That is from MSDN.
Now obviously the destination rectangle makes sense as this is the place it is supposed to go.

So my question is what does the term "source coordinates" mean and how would they have to do with loading a bitmap which comes from a separate file, not a previous place on the screen?

Also are these units relative to the screen or relative to the window? It doesn't make sense if it's relative to the screen because then what happens if you make the window smaller or move it around?

These are a couple of questions which I had trouble finding the answers for in documentation (they assume you already know) so I posted this here. Thank you for even reading this.

NoHero
July 17th, 2005, 12:40 PM
Those are relative to the DC. If the DC comes from a window, it is relative to the window. If it is the DC of the entire screen the coordinates are relative to the entire screen.

And for what the source coords are? Well for example you could just copy 100 pixels left, right, up and down of a source bitmap which has 400 pixels width and height into a destination.

Josef_Stalin
July 17th, 2005, 12:49 PM
Thank you. It makes sense now.

philkr
July 17th, 2005, 01:30 PM
You have also to take in account the difference between GetDC() and GetWindowDC(). GetDC() retrieves a device context for the client area only. GetWindowDC() retrieves a device context for the whole window including title bar, menus and scroll bars.
If you want the window without the titlebar you have to take for example y-coordinate 0 if you got the device context via GetDC(), if you got it via GetWindowDC() you will have to take 0 + the height of the titlebar and menus.