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
Printable View
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
You can use OleLoadPicture() look at this sample from MSDN: How to load graphics files and display them in Visual C++
Cheers
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
Sample code is helpful
bmp load should be easiest one to display image on dialog. anyways the way to load jpg is here.
m_jpg is the static picture control in which the image is being drawn.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);
Thanks
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