static bool ReduceOneMapFile( LPCTSTR lpszInFile, LPCTSTR lpszOutFile, PICTSAMPLEPARAM &fp, int level) { BOOL bRet; CMemBlock memInput( Size4MB ); CMemBlock memOutput( Size2MB ); CRuntimeClass *pInRT; CRuntimeClass *pOutRT = NULL; CPicture *pInPict; CPicture *pOutPict; CFile fileInput; CFile fileOutput; CPictSample filter; if( fileInput.Open( lpszInFile, CFile::modeRead | CFile::typeBinary ) ) { pInRT = ::GetWritablePictureType( &fileInput ); if( NULL == pOutRT ) pOutRT = pInRT; if( NULL != pInRT && NULL != ( pInPict = (CPicture*) pInRT->CreateObject() ) ) { if( fileOutput.Open( lpszOutFile, CFile::modeReadWrite | CFile::modeCreate | CFile::typeBinary ) ) { VERIFY( NULL != ( pOutPict = (CPicture*) pOutRT->CreateObject() ) ); if( pInPict->Attach( &fileInput ) && pInPict->ReadHeader() ) { if( pOutPict->Attach( &fileOutput ) ) { switch( pInPict->GetBitsPerSample() ) { case 1 : fp.sampleParam = 0; break; // case 8 : fp.sampleParam = level > 2 ? 3 : 0; break; // #HK050104 // case 8 : fp.sampleParam = level <= 2 ? 3 : 0; break; // #HK050120 case 8 : fp.sampleParam = 3; break; // #HK050120 } filter.SetFilterData( &fp.p ); bRet = filter.Filter( pInPict, pOutPict ); pOutPict->Detach(); } pInPict->Detach(); } fileOutput.Close(); delete pOutPict; } delete pInPict; } fileInput.Close(); } return TRUE == bRet ? 1 : 0; }
static bool GetReferenced( CFile& rFile, CString& rString, TOPOMAP& theMap ) { CRuntimeClass *pRT; if( NULL == ( pRT = GetPictureType( &rFile ) ) ); CPicture *pPict = (CPicture*) pRT->CreateObject(); VERIFY( pPict->Attach( &rFile ) && pPict->ReadHeader() ); long X0, Y0, X1, Y1; TAG tag270; GetPictInfo( pPict, X0, Y0, X1, Y1); if( pPict->GetTag( 270, tag270 ) ) { rString = tag270.strVal(); } delete pPict; ////////////////////////////////////////////////////////////////// // Karteninformation basteln theMap.m_sizeOfPicture.cx = X1; theMap.m_sizeOfPicture.cy = Y1; // GCP's: LinksUnten, RechtsUnten, RechtsOben, LinksOben GEOPOINT LO, RU; LO.X = 0; LO.Y = 0; RU.X = 0; RU.Y = 0; theMap.m_listOfGCP.erase( theMap.m_listOfGCP.begin(), theMap.m_listOfGCP.end() ); theMap.m_listOfGCP.push_back( GCP( GEOPOINT( LO.X, RU.Y, 0 ), GEOPOINT( 0, Y1, 0 ) ) ); theMap.m_listOfGCP.push_back( GCP( GEOPOINT( RU.X, RU.Y, 0 ), GEOPOINT( X1, Y1, 0 ) ) ); theMap.m_listOfGCP.push_back( GCP( GEOPOINT( RU.X, LO.Y, 0 ), GEOPOINT( X1, 0, 0 ) ) ); theMap.m_listOfGCP.push_back( GCP( GEOPOINT( LO.X, LO.Y, 0 ), GEOPOINT( 0, 0, 0 ) ) ); return true; }
static bool GetIntergraph( CFile& rFile, CString& rString, TOPOMAP& theMap ) { CRuntimeClass *pRT; bool bRet = false; if( NULL == ( pRT = GetPictureType( &rFile ) ) ); CPicture *pPict = (CPicture*) pRT->CreateObject(); VERIFY( pPict->Attach( &rFile ) && pPict->ReadHeader() ); long X0, Y0, X1, Y1; TAG tag270; TAG tag33918; GetPictInfo( pPict, X0, Y0, X1, Y1); if( pPict->GetTag( 33918, tag33918 ) ) { long nItems = tag33918.Count(); if( ( 4 + 64 ) == nItems ) { IGTAG33918* pData = (IGTAG33918*) tag33918.pVal(); _ASSERTE(sizeof(theMap.m_transform.m_matrix) == sizeof(pData->dblVal) ); memcpy( theMap.m_transform.m_matrix, pData->dblVal, sizeof(theMap.m_transform.m_matrix) ); ////////////////////////////////////////////////////////////////// // Karteninformation basteln theMap.m_sizeOfPicture.cx = X1; theMap.m_sizeOfPicture.cy = Y1; // GCP's: LinksUnten, RechtsUnten, RechtsOben, LinksOben theMap.m_listOfGCP.erase( theMap.m_listOfGCP.begin(), theMap.m_listOfGCP.end() ); theMap.m_listOfGCP.push_back( GCP( GEOPOINT( ), GEOPOINT( 0, Y1, 0 ) ) ); theMap.m_listOfGCP.push_back( GCP( GEOPOINT( ), GEOPOINT( X1, Y1, 0 ) ) ); theMap.m_listOfGCP.push_back( GCP( GEOPOINT( ), GEOPOINT( X1, 0, 0 ) ) ); theMap.m_listOfGCP.push_back( GCP( GEOPOINT( ), GEOPOINT( 0, 0, 0 ) ) ); bRet = true; } } delete pPict; return bRet; }
STDMETHODIMP CPictHolder::OpenPictureFile(BSTR strPicture) { Close(); CString S( strPicture ); if( !m_fileOfPicture.Open( S, CFile::modeRead | CFile::typeBinary ) ) return E_FAIL; CRuntimeClass *pRT; CPicture *pPict = NULL; HRESULT hr = E_FAIL; try { for(;;) { if( NULL == ( pRT = GetWritablePictureType( &m_fileOfPicture ) ) ) break; pPict = (CPicture*) pRT->CreateObject(); VERIFY( pPict->Attach( &m_fileOfPicture ) && pPict->ReadHeader() ); m_pPicture = pPict; hr = S_OK; break; } } catch(...) { if( pPict ) delete pPict; m_pPicture = NULL; } return hr; }
int MapInfo( const int argc, const char *argv[], istream& s_in, ostream& s_out, ostream& s_err ) { int c; bool bRaw = false; LPCTSTR optarg; int optind = 1; while( EOF != ( c = getopt( argc, argv, "rg?", optind, optarg ) ) ) { switch( c ) { case 'r' : bRaw = true; break; case 'g' : setlocale( LC_ALL, _T("German") ); break; case '?' : Usage( s_err ); return TRUE; } } if( argc < optind ) { Usage( s_err ); return FALSE; } CMemBlock memPict( Size4MB ); CRuntimeClass *pRT; CPicture *pPict; CFile fileInput; for( ; optind < argc; optind++ ) { if( fileInput.Open( argv[optind], CFile::modeRead | CFile::typeBinary ) ) { pRT = ::GetPictureType( &fileInput ); if( NULL != pRT && NULL != ( pPict = (CPicture*) pRT->CreateObject() ) ) { VERIFY( pPict->Attach( &fileInput ) && pPict->ReadHeader() ); pPict->DumpTags( s_out, bRaw ); pPict->Detach(); delete pPict; } else { s_err << _T("cannot determine FileType: ") << argv[optind] << endl; } fileInput.Close(); } else { s_err << _T("cannot open File: ") << argv[optind] << endl; } } return TRUE; }