Solved

displaying pixels

Posted on 2002-07-02
8
204 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Define unique primary key 9 95
notReplace  challenge 53 151
format the code in java 6 109
has22 challenge 11 106
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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.

685 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