| 1896 | } |
| 1897 | |
| 1898 | HBITMAP CRenderEngine::GenerateBitmap(CPaintManagerUI* pManager, CControlUI* pControl, RECT rc) |
| 1899 | { |
| 1900 | int cx = rc.right - rc.left; |
| 1901 | int cy = rc.bottom - rc.top; |
| 1902 | |
| 1903 | HDC hPaintDC = ::CreateCompatibleDC(pManager->GetPaintDC()); |
| 1904 | HBITMAP hPaintBitmap = ::CreateCompatibleBitmap(pManager->GetPaintDC(), rc.right, rc.bottom); |
| 1905 | ASSERT(hPaintDC); |
| 1906 | ASSERT(hPaintBitmap); |
| 1907 | HBITMAP hOldPaintBitmap = (HBITMAP) ::SelectObject(hPaintDC, hPaintBitmap); |
| 1908 | pControl->DoPaint(hPaintDC, rc); |
| 1909 | |
| 1910 | BITMAPINFO bmi = { 0 }; |
| 1911 | bmi.bmiHeader.biSize = sizeof(BITMAPINFOHEADER); |
| 1912 | bmi.bmiHeader.biWidth = cx; |
| 1913 | bmi.bmiHeader.biHeight = cy; |
| 1914 | bmi.bmiHeader.biPlanes = 1; |
| 1915 | bmi.bmiHeader.biBitCount = 32; |
| 1916 | bmi.bmiHeader.biCompression = BI_RGB; |
| 1917 | bmi.bmiHeader.biSizeImage = cx * cy * sizeof(DWORD); |
| 1918 | LPDWORD pDest = NULL; |
| 1919 | HDC hCloneDC = ::CreateCompatibleDC(pManager->GetPaintDC()); |
| 1920 | HBITMAP hBitmap = ::CreateDIBSection(pManager->GetPaintDC(), &bmi, DIB_RGB_COLORS, (LPVOID*) &pDest, NULL, 0); |
| 1921 | ASSERT(hCloneDC); |
| 1922 | ASSERT(hBitmap); |
| 1923 | if( hBitmap != NULL ) |
| 1924 | { |
| 1925 | HBITMAP hOldBitmap = (HBITMAP) ::SelectObject(hCloneDC, hBitmap); |
| 1926 | ::BitBlt(hCloneDC, 0, 0, cx, cy, hPaintDC, rc.left, rc.top, SRCCOPY); |
| 1927 | ::SelectObject(hCloneDC, hOldBitmap); |
| 1928 | ::DeleteDC(hCloneDC); |
| 1929 | ::GdiFlush(); |
| 1930 | } |
| 1931 | |
| 1932 | // Cleanup |
| 1933 | ::SelectObject(hPaintDC, hOldPaintBitmap); |
| 1934 | ::DeleteObject(hPaintBitmap); |
| 1935 | ::DeleteDC(hPaintDC); |
| 1936 | |
| 1937 | return hBitmap; |
| 1938 | } |
| 1939 | |
| 1940 | SIZE CRenderEngine::GetTextSize( HDC hDC, CPaintManagerUI* pManager , LPCTSTR pstrText, int iFont, UINT uStyle ) |
| 1941 | { |
nothing calls this directly
no test coverage detected