草庐IT

CreateCompatibleDC

全部标签

c++ - CreateCompatibleDC 的结果只有两种颜色

在下面的代码中,无论何时调用CreateCompatibleDC,生成的设备上下文只有两种颜色:黑色和白色。caseWM_PAINT:{PAINTSTRUCTps;ps.hdc=GetDC(g_CSkeletalViewerApp.m_hWnd);ps.fErase=true;RECTrc;GetWindowRect(g_CSkeletalViewerApp.m_hWnd,&rc);ps.rcPaint=rc;intwidth=rc.right-rc.left;intheight=rc.bottom-rc.top;HDChdc=BeginPaint(hWnd,&ps);HDCmemdc

c++ - CreateCompatibleDC 的奇怪错误

也许这是个愚蠢的问题,我不明白为什么我无法在以下代码中创建DC:HBITMAPCOcrDlg::LoadClippedBitmap(LPCTSTRpathName,UINTmaxWidth,UINTmaxHeight){HBITMAPhBmp=(HBITMAP)::LoadImage(NULL,pathName,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION);if(!hBmp)returnNULL;HDChdc=(HDC)GetDC();HDChdcMem=CreateCompatibleDC(hdc);if(!hdcMem)