Home > Software engineering >  How to improve the drawing speed StrechDIBits ()
How to improve the drawing speed StrechDIBits ()

Time:09-26

Consult a great god, and I use the MFC himself wrote a picture control, the use of GDI StrechDIBits () function mapping, slowly when painting a larger version, 300 million pixels 8-bit BMP figure, painting a secondary 2000-2400 milliseconds, that is, more than 2 seconds,

But with the company's library drawing as long as 6 to 20 milliseconds can finish, I want to ask what is the solution, is my problem or the function itself, or what is the optimal method,

SYSTEMTIME TimeStart, TimeEnd;
GetLocalTime (& amp; TimeStart);//start time
StretchDIBits (pDC - & gt; GetSafeHdc (), 0, 0, rcRect Width (), rcRect. Height (),
DImageXStartPos dImageYStartPos,
(int) (GetBitMapInfoHeader (.) biWidth/m_dZoomWidth), (int) (GetBitMapInfoHeader () biHeight/
M_dZoomHeight),
M_pcBufImage (BITMAPINFO *) m_pBitmapInfo_8, DIB_RGB_COLORS, SRCCOPY);
GetLocalTime (& amp; TimeEnd);//end time
Float fDetaTime=TimeEnd) wMilliseconds - TimeStart) wMilliseconds + 1000 * (TimeEnd) wSecond - TimeStart) wSecond);

CodePudding user response:

Change StretchDIBits first parameter to a memory DC and best operate pixels directly in memory bitmap operations, into a DIB format, directly to memcpy modified pixels

CodePudding user response:

In the memory DC painting, copy again

CodePudding user response:

Use DX?

CodePudding user response:

Brother can reply to the specific points on the second floor

CodePudding user response:

Similar with double buffering mechanism, save the file with a memory DC, DC to DC operation soon,

CodePudding user response:

Changes the D2D, I also in use recently, C: \ Program Files \ Microsoft Visual Studio (x86) 10.0 \ Samples \ 2052 \ VC2010SP1Samples there are many examples in the zip

CodePudding user response:

This API with before, I do have a very time consuming, suggest you search search better third-party libraries

CodePudding user response:

Has been solved, I do have a halftone takes seriously, with the memory DC + StretchDIBits can prevent screen flicker, but as slow StretchDIBits, I switched to STRETCH_DELETESCANS speed as fast as the company library, and some 300 million after a larger image to reduce the distortion, but look at the company library, distortion, same company library effect is slightly better than STRETCH_DELETESCANS began to shrink, just slightly better, with the method of estimation is also narrow is directly proportional sampling pixels, is not a difference,

I do is a mouse drag images, amplification, narrow, small picture doesn't matter, big image is slow, I can't find understand reason, actually StretchDIBits HALFTONE pattern really slow this function itself, but the effect is very good, if you want to do better, estimates that need to change a tool,

CodePudding user response:

Thank you, to summarize, think fast and don't think so estimated distortion wingdi or poor, can try other dx, for example, OpenGL
  • Related