Alternatives to FillRect
-
Hi, I'm doing a CPU-intensive program right now (C++ WinAPI, no MFC but I could use it if I had to) that uses some graphics, frequently calling a FillRect function to clear its back-buffered HDC to white. Is there a more efficient way to do this? Maybe by using bitwise operators somehow? Thanks!
KR
-
Hi, I'm doing a CPU-intensive program right now (C++ WinAPI, no MFC but I could use it if I had to) that uses some graphics, frequently calling a FillRect function to clear its back-buffered HDC to white. Is there a more efficient way to do this? Maybe by using bitwise operators somehow? Thanks!
KR
You could use a DIB section for the back buffer's bitmap and write the bits directly to memory in a loop. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
Hi, I'm doing a CPU-intensive program right now (C++ WinAPI, no MFC but I could use it if I had to) that uses some graphics, frequently calling a FillRect function to clear its back-buffered HDC to white. Is there a more efficient way to do this? Maybe by using bitwise operators somehow? Thanks!
KR
RECT r = {...}; SetBkColor(dc, your_white); ExtTextOut(dc, r.left, r.top, ETO_OPAQUE, &r, NULL, 0, NULL); [EDIT] Not saying it's faster, just another way. At one point i believe it was the prefered way (don't recall why). [/EDIT]
...cmk The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying. - John Carmack
-
You could use a DIB section for the back buffer's bitmap and write the bits directly to memory in a loop. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
You could use a DIB section for the back buffer's bitmap and write the bits directly to memory in a loop. Mark
Mark Salsbery Microsoft MVP - Visual C++ :java:
Using BitBlt API with WHITENESS isn't better?
- NS - [ODBaseBtn]
-
Using BitBlt API with WHITENESS isn't better?
- NS - [ODBaseBtn]
-
RECT r = {...}; SetBkColor(dc, your_white); ExtTextOut(dc, r.left, r.top, ETO_OPAQUE, &r, NULL, 0, NULL); [EDIT] Not saying it's faster, just another way. At one point i believe it was the prefered way (don't recall why). [/EDIT]
...cmk The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying. - John Carmack
-
That way seems to be faster than FillRect, but copying directly to memory with BitBlt is slightly faster. Thanks!
KR
You may want to read: http://blogs.msdn.com/oldnewthing/archive/2006/01/03/508694.aspx[^] However, if BitlBlt accepts hdcSrc = NULL when dwRop is WHITENESS then you may as well stick with that if it's faster. This is a special case (color is set to palette index 1 = usually white). ExtTextOut is still fastest for setting any color.
...cmk The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying. - John Carmack
-
BitBlt with WHITENESS seems to be the fastest way to do it that I've tried. I guess I might be able to get it a little faster using a straight memcpy but I think BitBlt basically is a memcpy already so I doubt it'll help much.
KR
Through BitBlt we can avoid the risk of bugs, since we dont need to handle the DC bitmap directly.
- NS - [ODBaseBtn]