Hi,
How can i show on a window an image, if it is tiff format/in jpg format,
by opening through the file menu, like open dialog and selecting the file name i.e. either tiff/jpg file
Thanking you
Printable View
Hi,
How can i show on a window an image, if it is tiff format/in jpg format,
by opening through the file menu, like open dialog and selecting the file name i.e. either tiff/jpg file
Thanking you
Also , pls. reference to this link : http://www.codeguru.com/Cpp/G-M/bitmap/.
Well...what is this code snippet supposed to do? Loading a JPEG as a bitmap? This will most-likely not work (at least I would be surprised if it would)?Quote:
Originally Posted by sunny_sz
Take a look at the following...Quote:
Originally Posted by ravirams
Thanks Andreas Masur's remind first . Maybe my misunderstand cause that I made a mistake .
Just like you post , I think I already understood ravirams's meaning .
In addition , I also want to attach my sample here , and I am sure that can works fine , and match to ravirams's requirments.
Code:CString filename;
TCHAR szFilters[] = _T("All Picture File(*.bmp,*.jpeg,*.jpg,*.gif,*.tiff)");
CMyFileDialog dlg(TRUE,_T(""),_T("*.*"),OFN_HIDEREADONLY|OFN_FILEMUSTEXIST,szFilters,AfxGetMainWnd());
if (dlg.DoModal () == IDOK)
{
filename = dlg.GetPathName();
}
else
{return;}
CString szFilename;
szFilename.Replace(".bmp",".jpeg");
HBITMAP hBmp = (HBITMAP)::LoadImage(
0,
szFilename,
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION
);
CDC *pDC;
pDC=GetDC();
CBitmap bmpHello;
bmpHello.Attach(hBmp);
BITMAP bm;
bmpHello.GetObject( sizeof(BITMAP), &bm );
CDC dcMem;
dcMem.CreateCompatibleDC( pDC );
CBitmap* pbmpOld = dcMem.SelectObject( &bmpHello );
pDC->BitBlt( 30,50, bm.bmWidth, bm.bmHeight,&dcMem, 0,0, SRCCOPY );
dcMem.SelectObject( pbmpOld );
ReleaseDC( pDC );
I also fail to see how this code will load any other file than a bitmap... :)Quote:
Originally Posted by Gunaamirthavelu
sorry for the mistake.
this code will display the image in Dialog Based appliction.
Code:CString filename;
TCHAR szFilters[] = _T("All Picture File(*.bmp,*.jpeg,*.jpg,*.gif,*.tiff)");
CMyFileDialog dlg(TRUE,_T(""),_T("*.*"),OFN_HIDEREADONLY|OFN_FILEMUSTEXIST,szFilters,AfxGetMainWnd());
if (dlg.DoModal () == IDOK)
{
filename = dlg.GetPathName();
}
else
{return;}
CString szFilename;
szFilename.Replace(".jpeg",".bmp");
HBITMAP hBmp = (HBITMAP)::LoadImage(
0,
szFilename,
IMAGE_BITMAP,
0,
0,
LR_LOADFROMFILE|LR_CREATEDIBSECTION
);
CDC *pDC;
pDC=GetDC();
CBitmap bmpHello;
bmpHello.Attach(hBmp);
BITMAP bm;
bmpHello.GetObject( sizeof(BITMAP), &bm );
CDC dcMem;
dcMem.CreateCompatibleDC( pDC );
CBitmap* pbmpOld = dcMem.SelectObject( &bmpHello );
pDC->BitBlt( 30,50, bm.bmWidth, bm.bmHeight,&dcMem, 0,0, SRCCOPY );
dcMem.SelectObject( pbmpOld );
ReleaseDC( pDC );
Gunamirthavelu, the code u have presented will work for only bitmaps.
To the OP. If you have time and patience to go through some code the following link will help you. It shows how to to load, save, display, transform BMP, JPEG, GIF, PNG, TIFF, MNG, ICO, PCX, TGA, WMF, WBMP, JBG, J2K images.
CXIMAGE
Edit:Sorry Andreas it seems I have provided the same link as you.