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

x
?
Solved

displaying pixels

Posted on 2002-07-02
8
Medium Priority
?
226 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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 1400 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

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.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
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.

830 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