本文整理汇总了C++中Box2i::extendBy方法的典型用法代码示例。如果您正苦于以下问题:C++ Box2i::extendBy方法的具体用法?C++ Box2i::extendBy怎么用?C++ Box2i::extendBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box2i
的用法示例。
在下文中一共展示了Box2i::extendBy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: imageData
void ImageDisplayDriver::imageData( const Box2i &box, const float *data, size_t dataSize )
{
Box2i tmpBox = box;
Box2i dataWindow = m_image->getDataWindow();
tmpBox.extendBy( dataWindow );
if ( tmpBox != dataWindow )
{
throw Exception("The box is outside image data window.");
}
int pixelSize = channelNames().size();
if ( dataSize != (box.max.x - box.min.x + 1) * (box.max.y - box.min.y + 1) * channelNames().size() )
{
throw Exception("Invalid dataSize value.");
}
int channel, targetX, targetY, sourceWidth, sourceHeight, targetWidth;
sourceWidth = box.max.x - box.min.x + 1;
sourceHeight = box.max.y - box.min.y + 1;
targetWidth = dataWindow.max.x - dataWindow.min.x + 1;
channel = 0;
targetX = box.min.x - dataWindow.min.x;
targetY = box.min.y - dataWindow.min.y;
for ( vector<string>::const_iterator it = channelNames().begin(); it != channelNames().end(); it++, channel++ )
{
vector< float > &target = boost::static_pointer_cast< FloatVectorData >(m_image->variables[ *it ].data)->writable();
vector< float >::iterator targetIt;
const float *sourceIt = data+channel;
targetIt = target.begin()+targetWidth*targetY+targetX;
for ( int y = 0; y < sourceHeight; y++ )
{
for ( int x = 0; x < sourceWidth; x++ )
{
*targetIt = *sourceIt;
sourceIt += pixelSize;
targetIt++;
}
targetIt += targetWidth - sourceWidth;
}
}
}
示例2: hash
void ImageSampler::hash( const Gaffer::ValuePlug *output, const Gaffer::Context *context, IECore::MurmurHash &h ) const
{
ComputeNode::hash( output, context, h );
if( output->parent<Plug>() == colorPlug() )
{
std::string channel = channelName( output );
if( channel.size() )
{
V2f pixel = pixelPlug()->getValue();
Box2i sampleWindow;
sampleWindow.extendBy( V2i( pixel ) - V2i( 1 ) );
sampleWindow.extendBy( V2i( pixel ) + V2i( 1 ) );
Sampler sampler( imagePlug(), channel, sampleWindow );
sampler.hash( h );
h.append( pixel );
}
}
}
示例3: compute
void ImageSampler::compute( Gaffer::ValuePlug *output, const Gaffer::Context *context ) const
{
if( output->parent<Plug>() == colorPlug() )
{
float sample = 0;
std::string channel = channelName( output );
if( channel.size() )
{
V2f pixel = pixelPlug()->getValue();
Box2i sampleWindow;
sampleWindow.extendBy( V2i( pixel ) - V2i( 1 ) );
sampleWindow.extendBy( V2i( pixel ) + V2i( 1 ) );
Sampler sampler( imagePlug(), channel, sampleWindow, Filter::create( filterPlug()->getValue() ) );
sample = sampler.sample( pixel.x, pixel.y );
}
static_cast<FloatPlug *>( output )->setValue( sample );
return;
}
ComputeNode::compute( output, context );
}
示例4: in
void
makeMultiView (const vector <string> &viewNames,
const vector <const char *> &inFileNames,
const char *outFileName,
Compression compression,
bool verbose)
{
Header header;
Image image;
FrameBuffer outFb;
//
// Find the size of the dataWindow, check files
//
Box2i d;
for (int i = 0; i < viewNames.size(); ++i)
{
InputFile in (inFileNames[i]);
if (verbose)
{
cout << "reading file " << inFileNames[i] << " "
"for " << viewNames[i] << " view" << endl;
}
if (hasMultiView (in.header()))
{
THROW (IEX_NAMESPACE::NoImplExc,
"The image in file " << inFileNames[i] << " is already a "
"multi-view image. Cannot combine multiple multi-view "
"images.");
}
header = in.header();
if (i == 0)
{
d=header.dataWindow();
}else{
d.extendBy(header.dataWindow());
}
}
image.resize (d);
header.dataWindow()=d;
// blow away channels; we'll rebuild them
header.channels()=ChannelList();
//
// Read the input image files
//
for (int i = 0; i < viewNames.size(); ++i)
{
InputFile in (inFileNames[i]);
if (verbose)
{
cout << "reading file " << inFileNames[i] << " "
"for " << viewNames[i] << " view" << endl;
}
FrameBuffer inFb;
for (ChannelList::ConstIterator j = in.header().channels().begin();
j != in.header().channels().end();
++j)
{
const Channel &inChannel = j.channel();
string inChanName = j.name();
string outChanName = insertViewName (inChanName, viewNames, i);
image.addChannel (outChanName, inChannel);
image.channel(outChanName).black();
header.channels().insert (outChanName, inChannel);
inFb.insert (inChanName, image.channel(outChanName).slice());
outFb.insert (outChanName, image.channel(outChanName).slice());
}
in.setFrameBuffer (inFb);
in.readPixels (in.header().dataWindow().min.y, in.header().dataWindow().max.y);
}
//
// Write the output image file
//
{
header.compression() = compression;
addMultiView (header, viewNames);
OutputFile out (outFileName, header);
//.........这里部分代码省略.........