Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. TextOut/DrawText is too slow

TextOut/DrawText is too slow

Scheduled Pinned Locked Moved C / C++ / MFC
comperformancehelpquestion
8 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Joe Smith IX
    wrote on last edited by
    #1

    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.

    C S J 3 Replies Last reply
    0
    • J Joe Smith IX

      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.

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      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.

      image processing toolkits | batch image processing

      A 1 Reply Last reply
      0
      • C Chris Losinger

        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.

        image processing toolkits | batch image processing

        A Offline
        A Offline
        Albert Holguin
        wrote on last edited by
        #3

        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).

        C 1 Reply Last reply
        0
        • A Albert Holguin

          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).

          C Offline
          C Offline
          Chris Losinger
          wrote on last edited by
          #4

          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.

          image processing toolkits | batch image processing

          A 1 Reply Last reply
          0
          • J Joe Smith IX

            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.

            S Offline
            S Offline
            Software_Developer
            wrote on last edited by
            #5

            How to make it faster: In the file ScrollerCtrl.cpp, set CScrollerCtrl::nSCROLL_DELAY to 1 and CScrollerCtrl::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";

            1 Reply Last reply
            0
            • C Chris Losinger

              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.

              image processing toolkits | batch image processing

              A Offline
              A Offline
              Albert Holguin
              wrote on last edited by
              #6

              That's true...

              J 1 Reply Last reply
              0
              • A Albert Holguin

                That's true...

                J Offline
                J Offline
                Joe Smith IX
                wrote on last edited by
                #7

                OK guys, thanks for the pointers. Let me try that approach.

                1 Reply Last reply
                0
                • J Joe Smith IX

                  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.

                  J Offline
                  J Offline
                  JackDingler
                  wrote on last edited by
                  #8

                  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[^]

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups