Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2015-01-30
4
Medium Priority
?
196 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 2000 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

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

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…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

927 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