Solved

Drawing an Oscilloscope (flickerfree & fast)

Posted on 1998-08-27
4
221 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 100 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

708 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now