[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Drawing an Oscilloscope (flickerfree & fast)

Posted on 1998-08-27
4
Medium Priority
?
286 Views
Last Modified: 2013-11-19
I want to display an oscilloscope in a window.  This oscilloscope would have a fixed grid, some fixed text, and the moving signal display.

Ideally the grid and text should be displayed BEHIND the signal, but this is not critical.

The grid and text should be flicker-free.

Finally the scope should not take too much processor time.  It is displaying the result of a fairly intensive calculation process, and I don't want to spend half my time just painting.

What is the best way to implement something like this in MFC?

Carlos
0
Comment
Question by:carlosn
  • 3
4 Comments
 
LVL 7

Accepted Solution

by:
psdavis earned 300 total points
ID: 1321406
Look at www.codeguru.com and there you will find two ways to perform flicker free drawing.  One uses a CMemDC method that is quite easy.  The other gives you a class that you will derive from.

Second, you may want to consider drawing all of your data into a precreated bitmap in your resource file.  (256 color is fine).  Then use LoadImage to access the bitmap and draw directly onto your bitmap.

Phillip
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1321407
Also take a quick look at DrawDibDraw and it's associated functions in the Video for Windows SDK.  I've used them briefly, but if you have a lot of images to display in a row it could be useful.

Also (and possibly best) you may want to choose your signal wisely, if you use the XOR pen to draw your data, then you can just erase the signal with another XOR drawing.  Then you won't have to redraw the entire bitmap at all.  Just XOR on and XOR off the signal.

Phillip
0
 
LVL 1

Author Comment

by:carlosn
ID: 1321408
Thank you, I'll have to check the XOR idea.

I have started using some of the memory DC, and found that the BitBlt was incredibly slow.  Is this normal?  Copying over a bitmap thats about 300x200 pixels, it was taking about 6% of the softwares time (according to the profiler).  Each BitBlt ran for about 2 ms, and the window is getting updated every 50 ms or so.
0
 
LVL 7

Expert Comment

by:psdavis
ID: 1321409
Yes, BitBlt is slow.  DrawDibDraw was created to be faster.

Good luck.

Phillip
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Displaying information on the statusbar.   Continuing from the third article about sudoku.   Open the project in visual studio. Status bar – let’s display the timestamp there.  We need to get the timestamp from the document s…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question