Beispiel #1
0
bool readMatchesFile( const string &aFilename, vector<PointMatch> &oVector, VersionedFileHeader *oHeader )
{
	ifstream f(aFilename.c_str(), ios::binary);
	if (!f) return false;

	VersionedFileHeader header;
	header.read_known(VFH_PointMatch, f);
	if ( oHeader!=NULL ) *oHeader=header;
	bool reverseByteOrder = ( header.isMSBF()!=MSBF_PROCESSOR() );

	try
	{
		switch (header.version())
		{
		case 0: readPointMatch_v0(f, oVector); break;
		case 1: readPointMatch_v1(f, reverseByteOrder, oVector); break;
		default: return false;
		}
	}
	catch (const bad_alloc &)
	{
		ELISE_DEBUG_ERROR(true, "readMatchesFile", "not enough memory to read file [" << aFilename << "]");
		return false;
	}

	return true;
}
bool multi_channels_read_raw_header( const string &i_filename, int &o_width, int &o_height, size_t &o_nbChannels, GenIm::type_el &o_type, VersionedFileHeader *o_header )
{
	ifstream f( i_filename.c_str(), ios::binary );
	if ( !f ) return false;

	VersionedFileHeader header;
	if ( !header.read_known( VFH_RawIm2D, f ) ) return false;
	if ( o_header!=NULL ) *o_header=header;
	bool reverseByteOrder = ( header.isMSBF()!=MSBF_PROCESSOR() );

	switch ( header.version() ){
	case 1:
		multi_channels_read_raw_header_v1( f, reverseByteOrder, o_width, o_height, o_nbChannels, o_type );
		break;
	default:
		__elise_debug_warning( true, "multi_channels_read_raw_header: unknown version number " << header.version() );
		return false;
	}
	return true;
}
bool MultiChannel<tData>::read_raw( const string &i_filename, VersionedFileHeader *o_header )
{
	ifstream f( i_filename.c_str(), ios::binary );
	if ( !f ) return false;

	VersionedFileHeader header;
	if ( !header.read_known( VFH_RawIm2D, f ) )
	{
		__elise_debug_warning( true, "MultiChannel<tData>::read_raw: cannot read versioned file header" );
		return false;
	}
	if ( o_header!=NULL ) *o_header=header;
	bool reverseByteOrder = ( header.isMSBF()!=MSBF_PROCESSOR() );

	switch ( header.version() ){
	case 1:
		return read_raw_v1( f, reverseByteOrder );
	default:
		__elise_debug_warning( true, "im2d_read_raw(iostream &, vector<Im2DGen*> &, VersionedFileHeader *): unknown version number "<<header.version() );
		return false;
	}
}