Solved

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

Posted on 2015-01-30
4
182 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
where is software market online? 7 107
Problem to file 3 74
windbg taking it's time 32 90
How can my static class become undefined?? 8 47
Many programs have tried to outwit PowerPoint in terms of technology and skill. These programs, however, still lack several characteristics that PowerPoint has possessed from the start. Here's why PowerPoint replacements won't entirely work for desi…
Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

813 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

8 Experts available now in Live!

Get 1:1 Help Now