当前位置: 首页>>代码示例>>C++>>正文


C++ DataTargetRef::providesFilePath方法代码示例

本文整理汇总了C++中DataTargetRef::providesFilePath方法的典型用法代码示例。如果您正苦于以下问题:C++ DataTargetRef::providesFilePath方法的具体用法?C++ DataTargetRef::providesFilePath怎么用?C++ DataTargetRef::providesFilePath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataTargetRef的用法示例。


在下文中一共展示了DataTargetRef::providesFilePath方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: if

ImageTargetFileQuartz::ImageTargetFileQuartz( DataTargetRef dataTarget, ImageSourceRef imageSource, ImageTarget::Options options, const std::string &extensionData )
    : cocoa::ImageTargetCgImage( imageSource, options )
{
    cocoa::SafeCfString uti = cocoa::createSafeCfString( extensionData );

    mImageDest = NULL;
    if( dataTarget->providesFilePath() ) {
        cocoa::SafeCfString pathString = cocoa::createSafeCfString( dataTarget->getFilePath().string() );
        const std::shared_ptr<__CFURL> urlRef( (__CFURL*)::CFURLCreateWithFileSystemPath( kCFAllocatorDefault, pathString.get(), kCFURLPOSIXPathStyle, false ), cocoa::safeCfRelease );
        mImageDest = ::CGImageDestinationCreateWithURL( urlRef.get(), uti.get(), 1, NULL );
    }
    else if( dataTarget->providesUrl() ) {
        std::shared_ptr<__CFURL> urlRef( (__CFURL*)cocoa::createCfUrl( dataTarget->getUrl() ), cocoa::safeCfRelease );
        mImageDest = ::CGImageDestinationCreateWithURL( urlRef.get(), uti.get(), 1, NULL );
    
    }
    else { // we'll wrap a cinder::OStream in a CGDataConsumer for output
        OStreamRef *ostreamRef = new OStreamRef( dataTarget->getStream() );
        ::CGDataConsumerCallbacks callbacks;
        callbacks.putBytes = cgDataConsumerPutBytes;
        callbacks.releaseConsumer = cgDataConsumerRelease;
        std::shared_ptr<CGDataConsumer> consumer( ::CGDataConsumerCreate( ostreamRef, &callbacks ), ::CGDataConsumerRelease );
        mImageDest = ::CGImageDestinationCreateWithDataConsumer( consumer.get(), uti.get(), 1, NULL );
    }
    
    if( ! mImageDest )
        throw ImageIoExceptionFailedWrite();
        
    setupImageDestOptions( options );
}
开发者ID:var-const,项目名称:azureland,代码行数:30,代码来源:ImageTargetFileQuartz.cpp

示例2: ImageIoExceptionFailedWrite

ImageTargetFileTinyExr::ImageTargetFileTinyExr( DataTargetRef dataTarget, ImageSourceRef imageSource, ImageTarget::Options options, const std::string & /*extensionData*/ )
{
    if( ! dataTarget->providesFilePath() ) {
        throw ImageIoExceptionFailedWrite( "ImageTargetFileTinyExr only supports writing to files." );
    }

    mFilePath = dataTarget->getFilePath();

    setSize( imageSource->getWidth(), imageSource->getHeight() );
    ImageIo::ColorModel cm = options.isColorModelDefault() ? imageSource->getColorModel() : options.getColorModel();
    
    switch( cm ) {
        case ImageIo::ColorModel::CM_RGB:
            mNumComponents = ( imageSource->hasAlpha() ) ? 4 : 3;
            setColorModel( ImageIo::ColorModel::CM_RGB );
            setChannelOrder( ( mNumComponents == 3 ) ? ImageIo::ChannelOrder::BGR : ImageIo::ChannelOrder::ABGR );
            if( mNumComponents == 3 )
                mChannelNames = { "G", "B", "R" };
            else
                mChannelNames = { "A", "G", "B", "R" };
        break;
        case ImageIo::ColorModel::CM_GRAY:
            mNumComponents = ( imageSource->hasAlpha() ) ? 2 : 1;
            setColorModel( ImageIo::ColorModel::CM_GRAY );
            setChannelOrder( ( mNumComponents == 2 ) ? ImageIo::ChannelOrder::YA : ImageIo::ChannelOrder::Y );
            if( mNumComponents == 2 )
                mChannelNames = { "Y", "A" };
            else
                mChannelNames = { "Y" };
        break;
        default:
            throw ImageIoExceptionIllegalColorModel();
    }

    // TODO: consider supporting half float and uint types as well
    setDataType( ImageIo::DataType::FLOAT32 );
    mData.resize( mHeight * imageSource->getWidth() * mNumComponents );
}
开发者ID:cinder,项目名称:cinder,代码行数:38,代码来源:ImageFileTinyExr.cpp

示例3: ImageIoExceptionFailedWrite

ImageTargetFileStbImage::ImageTargetFileStbImage( DataTargetRef dataTarget, ImageSourceRef imageSource, ImageTarget::Options options, const std::string &extensionData )
{
    if( ! dataTarget->providesFilePath() ) {
        throw ImageIoExceptionFailedWrite( "ImageTargetFileStbImage only supports writing to files." );
    }

    mFilePath = dataTarget->getFilePath();

    setSize( imageSource->getWidth(), imageSource->getHeight() );
    ImageIo::ColorModel cm = options.isColorModelDefault() ? imageSource->getColorModel() : options.getColorModel();
    
    switch( cm ) {
        case ImageIo::ColorModel::CM_RGB:
            mNumComponents = ( imageSource->hasAlpha() ) ? 4 : 3;
            setColorModel( ImageIo::ColorModel::CM_RGB );
            setChannelOrder( ( mNumComponents == 4 ) ? ImageIo::ChannelOrder::RGBA : ImageIo::ChannelOrder::RGB );
        break;
        case ImageIo::ColorModel::CM_GRAY:
            mNumComponents = ( imageSource->hasAlpha() ) ? 2 : 1;
            setColorModel( ImageIo::ColorModel::CM_GRAY );
            setChannelOrder( ( mNumComponents == 2 ) ? ImageIo::ChannelOrder::YA : ImageIo::ChannelOrder::Y );
        break;
        default:
            throw ImageIoExceptionIllegalColorModel();
    }

    mExtension = extensionData;
    if( mExtension == "hdr" ) { // Radiance files are always float*
        setDataType( ImageIo::DataType::FLOAT32 );
        mRowBytes = mNumComponents * imageSource->getWidth() * sizeof(float);
    }
    else {
        setDataType( ImageIo::DataType::UINT8 );
        mRowBytes = mNumComponents * imageSource->getWidth() * sizeof(float);
    }
    
    mData = std::unique_ptr<uint8_t[]>( new uint8_t[mWidth * mRowBytes] );
}
开发者ID:ARTisERR0R,项目名称:Cinder,代码行数:38,代码来源:ImageTargetFileStbImage.cpp


注:本文中的DataTargetRef::providesFilePath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。