| 发表于:2007-03-07 13:39:14 楼主 |
bool paintdib(hdc hdc, lprect lpdcrect, hdib hdib, lprect lpdibrect, hpalette hpal, dword dwrop) { lpbyte lpdibhdr; // pointer to bitmapinfoheader lpbyte lpdibbits; // pointer to dib bits bool bsuccess=false; // success/fail flag hpalette holdpal=null; // previous palette // check for valid dib handle if (!hdib) return false; // lock down the dib, and get a pointer to the beginning of the bit // buffer lpdibhdr = (lpbyte)globallock(hdib); lpdibbits = finddibbits(lpdibhdr); // if no palette provided, create one from dib if (! hpal) hpal = createdibpalette(lpdibhdr); // select and realize our palette as background if (hpal) { holdpal = selectpalette(hdc, hpal, true); realizepalette(hdc); } // make sure to use the stretching mode best for color pictures setstretchbltmode(hdc, coloroncolor); // call stretchdibits() with dwrop bsuccess = stretchdibits(hdc, lpdcrect-> left, lpdcrect-> top, rectwidth(lpdcrect), rectheight(lpdcrect), lpdibrect-> left, (int)dibheight(lpdibhdr) - lpdibrect-> top - rectheight(lpdibrect), rectwidth(lpdibrect), rectheight(lpdibrect), lpdibbits, (lpbitmapinfo)lpdibhdr, dib_rgb_colors, srccopy); // unlock the memory block globalunlock(hdib); // reselect old palette if (holdpal) selectpalette(hdc, holdpal, false); // return with success/fail flag return bsuccess; } 该函数是我看书时见到的一个函数其中stretchdibits函数中的参数不是很明白,主要是 lpdibrect-> left, (int)dibheight(lpdibhdr) - lpdibrect-> top - rectheight(lpdibrect),的含义尤其是 (int)dibheight(lpdibhdr) - lpdibrect-> top - rectheight(lpdibrect), 我不明白! 请高手指点 小弟在这里先行谢过了!! 谢谢!!!! |
|
|
|
|