TextOut/DrawText is too slow
-
Hello, I am looking into a full-screen text scrolling app, and found this at code project: [^] It is simple and fits my need. The only problem is that when I maximize it, its scrolling speed is way too slow (even when I take off the image and the delay iss set to 1ms). Can anyone give me some hints or pointers (sample code, maybe) on how I can make it faster? Thanks in advance.
-
Hello, I am looking into a full-screen text scrolling app, and found this at code project: [^] It is simple and fits my need. The only problem is that when I maximize it, its scrolling speed is way too slow (even when I take off the image and the delay iss set to 1ms). Can anyone give me some hints or pointers (sample code, maybe) on how I can make it faster? Thanks in advance.
looks like it draws all the text for each redraw. that will take a lot of time, if you have a lot of text to draw. not sure how to speed that up without a major reworking of the control, though. ideally, you would render the text to an offscreen bitmap (or many bitmaps) only when the text or the size changed. then, you'd copy that bitmap to the screen on each redraw.
-
looks like it draws all the text for each redraw. that will take a lot of time, if you have a lot of text to draw. not sure how to speed that up without a major reworking of the control, though. ideally, you would render the text to an offscreen bitmap (or many bitmaps) only when the text or the size changed. then, you'd copy that bitmap to the screen on each redraw.
Well, I think it does the complete redraw every time because it's a scrolling text control... which from the looks of it... they mean the text automatically scrolls through the screen (i.e. moving text).
-
Well, I think it does the complete redraw every time because it's a scrolling text control... which from the looks of it... they mean the text automatically scrolls through the screen (i.e. moving text).
but if the text isn't changing, and the layout isn't changing, then there's a performance boost to be gained by only drawing the text once onto an in-memory bitmap then bitbltting that bitmap for redraws. drawing a bitmap of dims X,Y is faster than rendering text and then drawing a bitmap of X,Y.
-
Hello, I am looking into a full-screen text scrolling app, and found this at code project: [^] It is simple and fits my need. The only problem is that when I maximize it, its scrolling speed is way too slow (even when I take off the image and the delay iss set to 1ms). Can anyone give me some hints or pointers (sample code, maybe) on how I can make it faster? Thanks in advance.
How to make it faster: In the file ScrollerCtrl.cpp, set
CScrollerCtrl::nSCROLL_DELAY
to 1 andCScrollerCtrl::nSCROLL_PAUSE
to 1. That should speed it up a bit.// defaults
const int CScrollerCtrl::nSCROLL_DELAY = 1; // time between each frame (milliseconds)
const int CScrollerCtrl::nSCROLL_PAUSE = 1; // time to pause before autoscrolling (milliseconds)
const int CScrollerCtrl::nMARGIN = 5; // (pixels)
const int CScrollerCtrl::nFONT_SIZE = 12; // (points)
const int CScrollerCtrl::nFONT_WEIGHT = FW_SEMIBOLD;
const char* CScrollerCtrl::szFONT_NAME = "Comic Sans MS"; -
but if the text isn't changing, and the layout isn't changing, then there's a performance boost to be gained by only drawing the text once onto an in-memory bitmap then bitbltting that bitmap for redraws. drawing a bitmap of dims X,Y is faster than rendering text and then drawing a bitmap of X,Y.
That's true...
-
That's true...
OK guys, thanks for the pointers. Let me try that approach.
-
Hello, I am looking into a full-screen text scrolling app, and found this at code project: [^] It is simple and fits my need. The only problem is that when I maximize it, its scrolling speed is way too slow (even when I take off the image and the delay iss set to 1ms). Can anyone give me some hints or pointers (sample code, maybe) on how I can make it faster? Thanks in advance.
Add MemDC to your project. That way your text drawing is done in memory, and then the entire screen is repainted in a flash. A sample can be found here: Flicker Free Drawing In MFC[^]