ImageSourceRef loadImage( DataSourceRef dataSource, ImageSource::Options options, string extension ) { #if defined( CINDER_COCOA ) cocoa::SafeNsAutoreleasePool autorelease; #endif if( extension.empty() ) extension = getPathExtension( dataSource->getFilePathHint() ); return ImageIoRegistrar::createSource( dataSource, options, extension ); }
std::unique_ptr<TargetFile> TargetFile::create( const DataTargetRef &dataTarget, size_t sampleRate, size_t numChannels, const std::string &extension ) { std::string ext = ( ! extension.empty() ? extension : getPathExtension( dataTarget->getFilePathHint() ) ); #if defined( CINDER_COCOA ) return std::unique_ptr<TargetFile>( new cocoa::TargetFileCoreAudio( dataTarget, sampleRate, numChannels, ext ) ); #elif defined( CINDER_MSW ) return std::unique_ptr<TargetFile>(); // TODO // return std::unique_ptr<TargetFile>( new msw::TargetFileMediaFoundation( dataTarget, sampleRate, numChannels, ext ) ); #endif }
void writeImage( DataTargetRef dataTarget, const ImageSourceRef &imageSource, ImageTarget::Options options, string extension ) { #if defined( CINDER_COCOA ) // this is necessary to limit the lifetime of the objc-based loader's allocations cocoa::SafeNsAutoreleasePool autorelease; #endif if( extension.empty() ) extension = getPathExtension( dataTarget->getFilePathHint() ); ImageTargetRef imageTarget = ImageIoRegistrar::createTarget( dataTarget, imageSource, options, extension ); if( imageTarget ) { writeImage( imageTarget, imageSource ); } else throw ImageIoExceptionUnknownExtension(); }
// static unique_ptr<SourceFile> SourceFile::create( const DataSourceRef &dataSource, size_t sampleRate ) { unique_ptr<SourceFile> result; if( getPathExtension( dataSource->getFilePathHint().extension().string() ) == "ogg" ) result.reset( new SourceFileOggVorbis( dataSource, sampleRate ) ); else { #if defined( CINDER_COCOA ) result.reset( new cocoa::SourceFileCoreAudio( dataSource, sampleRate ) ); #elif defined( CINDER_MSW ) result.reset( new msw::SourceFileMediaFoundation( dataSource, sampleRate ) ); #endif } if( result ) result->setupSampleRateConversion(); return result; }