-
May 19th, 2011, 05:02 AM
#1
Display an image in Gui
I got the image path from the file directory using the dlgOpen.GetPathName() function and it is saved to a char array eg path.I need to display it on Gui ,better on a new Dialog box.This image may be bmp or jpg.
Help required
-
May 19th, 2011, 06:34 AM
#2
Re: Display an image in Gui
You can use OleLoadPicture() look at this sample from MSDN: How to load graphics files and display them in Visual C++
Cheers
-
May 19th, 2011, 07:19 AM
#3
Re: Display an image in Gui
for bmp you dont need any coding. just draw a picture control on your dialog from resource editor in vc++ and add a bmp, you are done.
for jpg you need to use some functions such as OleLoadPicturePath() ie using some COM api. If you want I can provide you some code snippet
◄◄ hypheni ►►
-
May 19th, 2011, 10:01 AM
#4
Re: Display an image in Gui
-
May 19th, 2011, 10:26 AM
#5
Re: Display an image in Gui
bmp load should be easiest one to display image on dialog. anyways the way to load jpg is here.
Code:
IPicture *m_pic = NULL;
RECT rc;
CDC *pdc = NULL;
long hmWidth;
long hmHeight;
::OleLoadPicturePath(L"your_jpg_file", NULL, 0, 0, IID_IPicture, reinterpret_cast<void **>(&m_pic));
m_pic->get_Width(&hmWidth);
m_pic->get_Height(&hmHeight);
pdc = m_jpg.GetDC();
m_gif.GetClientRect(&rc);
m_pic->Render(pdc->m_hDC, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
0, hmHeight, hmWidth, -hmHeight, &rc);
m_pic->Release();
m_gif.ReleaseDC(pdc);
m_jpg is the static picture control in which the image is being drawn.
◄◄ hypheni ►►
-
May 19th, 2011, 10:16 PM
#6
Re: Display an image in Gui
-
May 20th, 2011, 07:13 AM
#7
Re: Display an image in Gui
But how change the height and width of the static control according to image height and width.For example 200 * 200 image ,the display also 200 * 200.for 64 * 64,the image also looks 64 *64.Now the problem is that the width and height on the dialog is same
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|