Solved

displaying pixels

Posted on 2002-07-02
8
174 Views
Last Modified: 2013-11-20
I am doing a project with a digital imaging chip.  I have a program in C++ that reads in a frame through the serial port and I would like to display these image frames in real-time.

How would I go about doing this in simple MFC?  I just need some sort of a dialog that I can throw some buttons on, then have a canvas/drawarea or something that I can refresh every time I get a new image.

Thanks in advance

0
Comment
Question by:Hep_Cat
8 Comments
 

Author Comment

by:Hep_Cat
ID: 7125259
Just to clarify, the image to display is only 22 x 22, and it is in a 2D array of grayscale ints (0-255).  I need to make the picture larger, i.e. each pixel in the image should take a block of pixels when displayed on the screen.  I need to know which class will let me do this and a little about how it works.
0
 
LVL 32

Expert Comment

by:jhance
ID: 7125294
A CStatic will display a CBitmap quite simply.
0
 
LVL 12

Expert Comment

by:migel
ID: 7125322
Hi!
You have to use DIB bitmap to show your picture since you know data format you can easy create needed DIB and fill it by needeed pixels
look at MSDN  for article
MSJ "March 1997" Q&A by Paul DiLASCIA
0
 

Author Comment

by:Hep_Cat
ID: 7125372
migel,

I don't have that article.  Creating a DIB or a CBitmap is not my problem.  What do I display them on and how can I update them in real-time as I get the information from the serial port (30 frames/sec)?  Animation?
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:Hep_Cat
ID: 7125380
migel,

I don't have that article.  Creating a DIB or a CBitmap is not my problem.  What do I display them on and how can I update them in real-time as I get the information from the serial port (30 frames/sec)?  Animation?
0
 

Author Comment

by:Hep_Cat
ID: 7125412
Sample code would be a great help
0
 
LVL 49

Accepted Solution

by:
DanRollins earned 350 total points
ID: 7125587
Make a dialog-based app.  
Add a CStatic control to it (it's tool palette icon looks like a cactus)
Right-click and...
  ... set its ID to IDC_MyBitmap
  ... set Type to Bitmap
  click OK
Press Ctrl+W and in the ClassWizard and click the 'Member Variables' tab
Select ICD_MyBitmap
Click [Add Variable]
  name is: m_ctlMyBitmap
  cateogory: is Control
  vriable type: CStatic
=--==-=-=-=-=-
Now you have a canvas and an easy way to update it.

Once you have an HBITMAP, created from the image data, you can simply use:

    m_ctlMyBitmap.SetBitmap( hBmp );

Do this in a loop to get Real Time Animation!
To increase the size, just create twice as large of a bitmap (use StretchBlt or StetchDIBits).  You say you'll have no trouble creating a DIB, so that should be easy for you.

-- Dan
0
 

Author Comment

by:Hep_Cat
ID: 7127836
That's what I needed!  Thanks
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

706 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

17 Experts available now in Live!

Get 1:1 Help Now