Ejemplo n.º 1
0
ObjectPtr EXRImageReader::doOperation( const CompoundObject *operands )
{
	ImagePrimitivePtr image = staticPointerCast< ImagePrimitive >( ImageReader::doOperation( operands ) );
	if ( image )
	{
		headerToCompoundData( m_inputFile->header(), image->blindData() );
	}
	return image;
}
Ejemplo n.º 2
0
IECore::ImagePrimitivePtr ImagePlug::image() const
{
	Format format = formatPlug()->getValue();
	Box2i dataWindow = dataWindowPlug()->getValue();
	Box2i newDataWindow( Imath::V2i(0) );

	if( dataWindow.isEmpty() )
	{
		dataWindow = Box2i( Imath::V2i(0) );
	}
	else
	{
		newDataWindow = format.yDownToFormatSpace( dataWindow );
	}

	// use the default format if we don't have an explicit one.
	/// \todo: remove this once FormatPlug is handling it for
	/// us during ExecutableNode::execute (see issue #887).
	if( format.getDisplayWindow().isEmpty() )
	{
		format = Context::current()->get<Format>( Format::defaultFormatContextName, Format() );
	}
	
	ImagePrimitivePtr result = new ImagePrimitive( newDataWindow, format.getDisplayWindow() );
	
	ConstCompoundObjectPtr metadata = metadataPlug()->getValue();
	compoundObjectToCompoundData( metadata.get(), result->blindData() );
	
	ConstStringVectorDataPtr channelNamesData = channelNamesPlug()->getValue();
	const vector<string> &channelNames = channelNamesData->readable();

	vector<float *> imageChannelData;
	for( vector<string>::const_iterator it = channelNames.begin(), eIt = channelNames.end(); it!=eIt; it++ )
	{
		FloatVectorDataPtr cd = new FloatVectorData;
		vector<float> &c = cd->writable();
		c.resize( result->variableSize( PrimitiveVariable::Vertex ), 0.0f );
		result->variables[*it] = PrimitiveVariable( PrimitiveVariable::Vertex, cd );
		imageChannelData.push_back( &(c[0]) );
	}

	parallel_for( blocked_range3d<size_t>( 0, imageChannelData.size(), 1, 0, dataWindow.size().x+1, tileSize(), 0, dataWindow.size().y+1, tileSize() ),
		      GafferImage::Detail::CopyTiles( imageChannelData, channelNames, channelDataPlug(), dataWindow, Context::current(), tileSize()) );

	return result;
}
Ejemplo n.º 3
0
IECore::ImagePrimitivePtr ImagePlug::image() const
{
    Format format = formatPlug()->getValue();
    Box2i dataWindow = dataWindowPlug()->getValue();
    Box2i newDataWindow( Imath::V2i(0) );

    if( dataWindow.isEmpty() )
    {
        dataWindow = Box2i( Imath::V2i(0) );
    }
    else
    {
        newDataWindow = format.yDownToFormatSpace( dataWindow );
    }

    ImagePrimitivePtr result = new ImagePrimitive( newDataWindow, format.getDisplayWindow() );

    ConstCompoundObjectPtr metadata = metadataPlug()->getValue();
    compoundObjectToCompoundData( metadata.get(), result->blindData() );

    ConstStringVectorDataPtr channelNamesData = channelNamesPlug()->getValue();
    const vector<string> &channelNames = channelNamesData->readable();

    vector<float *> imageChannelData;
    for( vector<string>::const_iterator it = channelNames.begin(), eIt = channelNames.end(); it!=eIt; it++ )
    {
        FloatVectorDataPtr cd = new FloatVectorData;
        vector<float> &c = cd->writable();
        c.resize( result->variableSize( PrimitiveVariable::Vertex ), 0.0f );
        result->variables[*it] = PrimitiveVariable( PrimitiveVariable::Vertex, cd );
        imageChannelData.push_back( &(c[0]) );
    }

    parallel_for( blocked_range2d<size_t>( 0, dataWindow.size().x+1, tileSize(), 0, dataWindow.size().y+1, tileSize() ),
                  GafferImage::Detail::CopyTiles( imageChannelData, channelNames, channelDataPlug(), dataWindow, Context::current(), tileSize()) );

    return result;
}