读书人

win32api 位图 请问

发布时间: 2013-01-01 14:04:18 作者: rapoo

win32api 位图 请教
编辑的位图(11*11):
win32api  位图 请问


实际显示的位图:
win32api  位图 请问


WM_PAINT主要代码:

hdc=BeginPaint(hwnd,&ps);

hBitmap=LoadBitmap(hInstance,MAKEINTRESOURCE(IDB_BITMAP2));
GetObject(hBitmap,sizeof(BITMAP),&bitmap);
cxSource=bitmap.bmWidth;
cySource=bitmap.bmHeight;

hdcBitmap=CreateCompatibleDC(NULL);
SelectObject(hdcBitmap,hBitmap);
StretchBlt(hdc,cx,cy,cxSource,cySource,hdcBitmap,0,0,cxSource,cySource,NULL);

DeleteDC(hdcBitmap);
EndPaint(hwnd,&ps);



这是哪一步漏掉了?怎么绘制出一个黑色正方形呢?
位图这部分看了好几天了;真就是一点一点啃;还经常啃不动;
另外还有个问题,看到有的函数需要一个颜色平面的参数,这个颜色平面到底是个什么?以前问过一次,没得到什么易懂的回复,还是无法理解;
[解决办法]
StretchBlt(hdc,cx,cy,cxSource,cySource,hdcBitmap,0,0,cxSource,cySource,NULL);
函的最後一有。


http://blog.sina.com.cn/s/blog_49a7b62b010009f4.html

建用SRCCOPY,即:
StretchBlt(hdc,cx,cy,cxSource,cySource,hdcBitmap,0,0,cxSource,cySource,SRCCOPY);

读书人网 >C++

热点推荐