
Obsolete Procedures
/*void CopyRGBSwitch( unsigned char *ptrOut, unsigned char * ptrIn, int pixels)
{
	for (int i=0;i<pixels;i++) {
		*ptrOut = *(ptrIn+2);
		ptrOut++;
		*ptrOut = *(ptrIn+1);
		ptrOut++;
		*ptrOut = *ptrIn;
		ptrOut++;
		ptrIn+=3;
	}

}*/


BOOL CJpegTestDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
	//
	AfxMessageBox( lpszPathName);
		char SelectedFile[ 500];
	strcpy( SelectedFile, lpszPathName);
	//		strcpy( SelectedFile, AfxGetApp( )->m_lpCmdLine);
	int FileType = ExtentionType( SelectedFile);
	if (FileType <1) 
	{
		strcpy( SelectedFile, AfxGetApp( )->m_lpCmdLine);
		AfxMessageBox( lpszPathName);
		FileType = ExtentionType( SelectedFile);
		if (FileType <1) return FALSE;
	}
// Here the file type = .ft .bmp, .jpg
//

	CFile file;
	CFileException fe;
	if (!file.Open(lpszPathName, CFile::modeRead | CFile::shareDenyWrite, &fe))
	{
		ReportSaveLoadException(lpszPathName, &fe, FALSE, AFX_IDP_FAILED_TO_OPEN_DOC);
		return FALSE;
	}

	DeleteContents();
	BeginWaitCursor();

	// replace calls to Serialize with ReadBMPFile function
	TRY
	{
		ReadBMPFile(file, m_hBMP, m_IsWin30, m_sizeDoc, m_NrOfColors, m_PaletteSize, m_Planes, m_BitsPixel);
		ShowInt( "size", m_sizeDoc.cx, m_sizeDoc.cy, m_NrOfColors, m_PaletteSize, m_Planes, m_BitsPixel);
	}
	CATCH (CFileException, eLoad)
	{
		file.Abort(); // will not throw an exception
		EndWaitCursor();
		ReportSaveLoadException(lpszPathName, eLoad, FALSE, AFX_IDP_FAILED_TO_OPEN_DOC);
		m_hBMP = NULL;
		return FALSE;
	}
	END_CATCH

	InitBmpData();
	EndWaitCursor();

	if (m_hBMP == NULL)
	{
		// may not be BMP format
		CString strMsg;
//		strMsg.LoadString(IDS_CANNOT_LOAD_BMP);
		AfxMessageBox( "Cannot load bmp.", MB_ICONINFORMATION | MB_OK);
		return FALSE;
	}
	SetPathName(lpszPathName);
	SetModifiedFlag(FALSE);     // start off with unmodified
	return TRUE;
}

// BmpAPI-2.h
//BOOL  WINAPI CreateBMPPalette(HBITMAP hBmp, CPalette* cPal, bool IsWin30);
// int      WINAPI  BMPNumColors (const unsigned char * lpbi, bool IsWin30, unsigned char * &PalettePtr);
//bool WINAPI SaveBMP(CFile& file, HBITMAP hBmp, int PaletteSize); 
//bool WINAPI ReadBMPFile(CFile& file, HBITMAP &hBmp, bool &IsWin30, CSize &size, int &NrOfColors, int &PaletteSize, int &planes, int &BitsPixel);
//bool ReadBMPFileTo3Bytes(CFile& file, HBITMAP &hBmp, bool &IsWin30, CSize &size, int &NrOfColors, int &PaletteSize, int &planes, int &BitsPixel);

void CJpegTestView::OnToolsReadjpeg() 
{
	// TODO: Add your command handler code here
	CFileDialog dlg( true, ".jpg", "*.jpg", 
		OFN_ENABLESIZING|OFN_HIDEREADONLY,
		_T("Jpeg files(*.jpg)|*.jpg|")
		_T("All files(*.*)|*.*|") _T("|") );
	if (IDOK != dlg.DoModal()) return;
	CJpegTestDoc *pDoc = GetDocument();
	read_JPEG_file( dlg.GetPathName(), pDoc->m_hBMP, pDoc->m_sizeDoc);
	SetScrollSizes(MM_TEXT, pDoc->GetDocSize()+m_ViewOffset);
	Invalidate();
}

void CJpegTestView::OnToolsWritejpeg() 
{
	// TODO: Add your command handler code here
	CFileDialog dlg( false, ".jpg", "*.jpg", 
		OFN_ENABLESIZING|OFN_OVERWRITEPROMPT|OFN_HIDEREADONLY,
		_T("Jpeg files(*.jpg)|*.jpg|")
		_T("All files(*.*)|*.*|") _T("|") );
	if (IDOK != dlg.DoModal()) return;
	CJpegTestDoc *pDoc = GetDocument();
	if (!write_JPEG_file( dlg.GetPathName(), pDoc->m_hBMP, GlobalJpegQuality ) )
		AfxMessageBox( _T("Save Jpeg File: ") + dlg.GetFileTitle( ) + " Failed") ;
	
	
}
