Click to See Complete Forum and Search --> : open and read JPEG and BMP file


reddybk1
December 4th, 2004, 04:33 AM
Can anyone help me in the program which can open and read jpeg and bmp file..this should be coded in VC++ ...i am having problems in coding....

Thanks in advance

Ajay Vijay
December 4th, 2004, 04:38 AM
Complex: HowTo (http://support.microsoft.com/default.aspx?scid=kb;en-us;158898)
Easy: CImage (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/vcrefCImageCImage.asp)

Andreas Masur
December 4th, 2004, 07:27 AM
[ Moved thread ]

ashsri
December 4th, 2004, 09:33 PM
Use this code....I have used CXIMAGE,which can be downloaded at http://www.xdp.it/, and more info for this can be found in the same website or even in codeproject.com. Do all the details given in codeproject.com at http://www.codeproject.com/bitmap/cximage.asp which is really a big help. add #include "ximage.h" and #include "xfile.h". then add this code at the Onopen()

CFileDialog FileDlg(TRUE,"jpeg;jpg;bmp;tif;png", "*.jpeg;*.jpg;*.bmp;*.tif;*.png", OFN_OVERWRITEPROMPT,"Image Files (*.jpeg,*.jpg,*.bmp,*.tif,*.png)", NULL);


if (FileDlg.DoModal()==IDOK)
{
Inside=FileDlg.GetPathName();
// AfxMessageBox (Inside);
First=FileDlg.GetFileExt();
// AfxMessageBox (First);
CString Ash=FileDlg.GetFileTitle();
SetWindowText(Ash);
Second=FileDlg.GetPathName();

}
else
{

}
if ((First=="jpg") || (First=="jpeg") || (First=="JPG") || (First=="JPEG"))
ImageType=CXIMAGE_FORMAT_JPG;
if ((First=="tif") || (First=="TIF"))
ImageType=CXIMAGE_FORMAT_TIF;
if ((First=="png") || (First=="PNG"))
ImageType=CXIMAGE_FORMAT_PNG;
else
ImageType=CXIMAGE_FORMAT_BMP;

ImageIn.Load(Inside,ImageType);
ImageOut.Load(Inside,ImageType);
NewImage.Load(Inside,ImageType);

}

ImageIn, ImageOut, NewImage are of CxImage type and first,second are of CString type, (type this is the class view - filenamedlg)


hope this works....good luck