Solved

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

Posted on 2015-01-30
4
191 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Industry Leaders: 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!

Question has a verified solution.

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

Suggested Solutions

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

738 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