bool FileFormatInstance::Open( ImageDescriptionArray& images, const String& filePath, const IsoString& hints ) { images.Clear(); if ( (*API->FileFormat->OpenImageFileEx)( handle, filePath.c_str(), hints.c_str(), 0/*flags*/ ) == api_false ) return false; for ( uint32 i = 0, n = (*API->FileFormat->GetImageCount)( handle ); i < n; ++i ) { IsoString id; size_type len = 0; (*API->FileFormat->GetImageId)( handle, 0, &len, i ); if ( len > 0 ) { id.SetLength( len ); if ( (*API->FileFormat->GetImageId)( handle, id.Begin(), &len, i ) == api_false ) throw APIFunctionError( "GetImageId" ); id.ResizeToNullTerminated(); } api_image_info info; api_image_options options; if ( (*API->FileFormat->GetImageDescription)( handle, &info, &options, i ) == api_false ) throw APIFunctionError( "GetImageDescription" ); ImageDescription d; d.id = id; APIImageInfoToPCL( d.info, info ); APIImageOptionsToPCL( d.options, options ); images.Add( d ); } return true; }
IsoString ProcessParameter::Id() const { size_type len = 0; (*API->Process->GetParameterIdentifier)( m_data->handle, 0, &len ); IsoString id; if ( len > 0 ) { id.SetLength( len ); if ( (*API->Process->GetParameterIdentifier)( m_data->handle, id.c_str(), &len ) == api_false ) throw APIFunctionError( "GetParameterIdentifier" ); id.ResizeToNullTerminated(); } return id; }
IsoString FileFormat::Name() const { size_type len = 0; (*API->FileFormat->GetFileFormatName)( m_data->handle, 0, &len ); IsoString name; if ( len > 0 ) { name.SetLength( len ); if ( (*API->FileFormat->GetFileFormatName)( m_data->handle, name.c_str(), &len ) == api_false ) throw APIFunctionError( "GetFileFormatName" ); name.ResizeToNullTerminated(); } return name; }
IsoString View::FullId() const { size_type len = 0; (*API->View->GetViewFullId)( handle, 0, &len ); IsoString id; if ( len > 0 ) { id.SetLength( len ); if ( (*API->View->GetViewFullId)( handle, id.c_str(), &len ) == api_false ) throw APIFunctionError( "GetViewFullId" ); id.ResizeToNullTerminated(); } return id; }
IsoStringList ProcessParameter::Aliases() const { size_type len = 0; (*API->Process->GetParameterAliasIdentifiers)( m_data->handle, 0, &len ); IsoStringList aliases; if ( len > 0 ) { IsoString csAliases; csAliases.SetLength( len ); if ( (*API->Process->GetParameterAliasIdentifiers)( m_data->handle, csAliases.c_str(), &len ) == api_false ) throw APIFunctionError( "GetParameterAliasIdentifiers" ); csAliases.ResizeToNullTerminated(); csAliases.Break( aliases, ',' ); } return aliases; }
bool FileFormatInstance::ReadColorFilterArray( ColorFilterArray& cfa ) { try { cfa = ColorFilterArray(); if ( (*API->FileFormat->BeginColorFilterArrayExtraction)( handle ) == api_false ) return false; size_type patternLen = 0, nameLen = 0; (*API->FileFormat->GetImageColorFilterArray)( handle, 0, &patternLen, 0, 0, 0, &nameLen ); bool ok = true; if ( patternLen > 0 ) { IsoString pattern; pattern.SetLength( patternLen ); String name; if ( nameLen > 0 ) name.SetLength( nameLen ); int32 width, height; ok = (*API->FileFormat->GetImageColorFilterArray)( handle, pattern.Begin(), &patternLen, &width, &height, name.Begin(), &nameLen ) != api_false; if ( ok ) { pattern.ResizeToNullTerminated(); name.ResizeToNullTerminated(); cfa = ColorFilterArray( pattern, width, height, name ); } } (*API->FileFormat->EndColorFilterArrayExtraction)( handle ); return ok; } catch ( ... ) { (*API->FileFormat->EndColorFilterArrayExtraction)( handle ); throw; } }
ProcessParameter::enumeration_element_list ProcessParameter::EnumerationElements() const { if ( !IsEnumeration() ) return enumeration_element_list(); size_type count = (*API->Process->GetParameterElementCount)( m_data->handle ); if ( count == 0 ) throw APIFunctionError( "GetParameterElementCount" ); enumeration_element_list elements( count ); for ( size_type i = 0; i < count; ++i ) { size_type len = 0; (*API->Process->GetParameterElementIdentifier)( m_data->handle, i, 0, &len ); if ( len == 0 ) throw APIFunctionError( "GetParameterElementIdentifier" ); elements[i].id.SetLength( len ); if ( (*API->Process->GetParameterElementIdentifier)( m_data->handle, i, elements[i].id.c_str(), &len ) == api_false ) throw APIFunctionError( "GetParameterElementIdentifier" ); elements[i].id.ResizeToNullTerminated(); len = 0; (*API->Process->GetParameterElementAliasIdentifiers)( m_data->handle, i, 0, &len ); if ( len > 0 ) { IsoString aliases; aliases.SetLength( len ); if ( (*API->Process->GetParameterElementAliasIdentifiers)( m_data->handle, i, aliases.c_str(), &len ) == api_false ) throw APIFunctionError( "GetParameterElementAliasIdentifiers" ); aliases.ResizeToNullTerminated(); aliases.Break( elements[i].aliases, ',' ); } elements[i].value = (*API->Process->GetParameterElementValue)( m_data->handle, i ); } return elements; }