Solved

What is the best method for rendering bitmaps in an MS windows application window?

Posted on 2015-01-30
4
174 Views
Last Modified: 2015-01-30
Hi:

I'm building a windows based application which will display bitmap frames.
Basically I'm capturing individual frames from a pc camera; doing some analysis
and then wanting to display that frame in a window.

Our current implementation is a 32 bit application  is written in unmanaged C++ .

I've looked at the opencv implementation -->> cv::imshow().
Under the covers, what they are doing would work for us.

But,  rather than have opencv own the window, we want our app to,
so we can add some additional processing.

opencv's implementation is old school windows with doing BitBlt() and StretchBlt()
during the WM_PAINT messages of the target window (owner draw).

Are there other approaches out there which would answer our needs?
Does GDI++ provide any "rendering an image to a target window" functionality?

If our target changed to be a managed winforms or WPF application, what would be the
best prescribed approach?

Thanks in advice for your advice,

JohnB
0
Comment
Question by:jxbma
  • 2
  • 2
4 Comments
 
LVL 86

Expert Comment

by:jkr
ID: 40580770
Are you thinking of something like

void DrawBitmap(HWND hwnd, Gdiplus::Image* pImg) {

  Gdiplus::Graphics graphics(hwnd);
  Gdiplus::Rect rc(0, 0, 800, 400);
  graphics.DrawImage(pImg, rc);
}

// ...

Gdiplus::Image img(L"c:\\path\\image.bmp", FALSE);

DrawBitmap(hwndMyWindow,&img);

Open in new window

?

See also https://msdn.microsoft.com/en-us/library/windows/desktop/ms534462%28v=vs.85%29.aspx ("Image class") and https://msdn.microsoft.com/en-us/library/windows/desktop/ms536051%28v=vs.85%29.aspx ("Graphics.DrawImage(Image*, const Rect) method")
0
 
LVL 1

Author Comment

by:jxbma
ID: 40580791
jkr:: Yes sir, as usual you are spot on your game.

I guess an additional question is:

Would I do this as an "owner draw" in my WM_PAINT message?

Do I have to worry about stretching as the parent window resizes?

Thanks,
JB
0
 
LVL 86

Accepted Solution

by:
jkr earned 500 total points
ID: 40580799
You can of course do that in yoru WM_PAINT handler, 'owner draw' style or not. If you want to use the window's corners as the 'Rect' used with 'DrawImage()', yes, then stretching would be an issue. If you however use the same seize regardless of the window's actual size, there won't be a problem.
0
 
LVL 1

Author Closing Comment

by:jxbma
ID: 40580848
Right as usual!

Thanks,
JB
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C++ question 3 62
Would like to record audio portion of Skype Video Call on Mac 2 78
Need more details 5 125
Stream live video from Raspberry Pi camera 22 115
In this article, I'll explain how to setup a Plex Media Server (https://plex.tv/) on a Redhat (Centos) 7 based NAS with screenshots to help those looking for assistance.  What is Plex? If you aren't familiar with Plex, it’s a DLNA media serv…
Tired of waiting for your show or movie to load?  Are buffering issues a constant problem with your internet connection?  Check this article out to see if these simple adjustments are the solution for you.
Viewers will learn the basics of making and using Impulse Kits in Ableton Live. Load new Impulse into an empty MIDI track: Fill the 8 empty sample slots with drum samples: Adjust parameters to tailor each sound as desired: Proceed to create be…
Viewers will learn how to include realistic velocity sensitivity to their Sampler instruments. Set the Vol<Vel parameter in the Filter/Global tab to your desired setting: Gather samples of hits of various intensity, and drag/drop into Velocity zon…

920 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

15 Experts available now in Live!

Get 1:1 Help Now