I want to create a large CompatibleDC, draw a large image on it, and then add part of the image to another DC in order to achieve high performance.
I use the following code to create a compatible DC. But when the rectangle becomes very large, etc .: 5000 * 5000, the created CompatibleDC becomes unstable. sometimes it’s normal, sometimes it fails. is there something wrong with my code?
input :pInputDC output:pOutputMemDC { pOutputMemDC=new CDC(); VERIFY(pOutputMemDC->CreateCompatibleDC(pInputDC)); CRect rect(0,0,nDCWidth,nDCHeight); CBitmap bitmap; if (bitmap.CreateCompatibleBitmap(pInputDC, rect.Width(), rect.Height())) { pOutputMemDC->SetViewportOrg(-rect.left, -rect.top); m_pOldBitmap = pOutputMemDC->SelectObject(&bitmap); } CBrush brush; VERIFY(brush.CreateSolidBrush(RGB(255,0, 0))); brush.UnrealizeObject(); pOutputMemDC->FillRect(rect, &brush); }
, DC blitting , DC, DC , DC, , , , blit-. (-x, -y) , . (100 200) - (400 400) , DC (300x200) (-100, -200).
: -, . -, GDI DC ( ). , , , .
, DC - - (, JPEG), . , , , / / . - DC, DC DC. , , , .
5000x5000 . 100 . , , .
1 , , , . . ? , , ?
, , .
Make sure you select all the original GDI objects for the domain controllers.
The problem may be that your Bitmap is still selected in pOutputMemDC when it is destroyed, and one or both of them cannot be deleted properly. Therefore, memory problems may begin.
Source: https://habr.com/ru/post/1708624/More articles:Applications based on CMenu and Dialog - visual-c ++How can I count the number of properties in a structure in MATLAB? - matlabIs there any difference between SetupResult and Stub in RhinoMocks? - c #Extrapolation of cubic splines - plotHow to combine two lines with Jet.OLEDB.4.0 provider - xmlC # for VB6 COM events ("an object or class does not support a set of events") - c #https://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1708626/having-a-cgi-script-catch-all-requests-to-a-domain-with-apache&usg=ALkJrhi1pDMqZZvWXLnHn042ccYPgESevgНужно ли сериализовать свойства при использовании состояния сеанса sqlserver для .net 3.5 framework и IIS 7.0 - .nethttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1708628/c-class-to-xml-xmlserializaion-problem&usg=ALkJrhjQaQGmmNfz8y05Z4acAMb4PR6xbgHow to use Google search results in Excel VBA? - vbaAll Articles