• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ channellist::ConstIterator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中channellist::ConstIterator的典型用法代码示例。如果您正苦于以下问题:C++ ConstIterator类的具体用法?C++ ConstIterator怎么用?C++ ConstIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: int

void
ChannelListAttribute::writeValueTo (OStream &os, int version) const
{
    for (ChannelList::ConstIterator i = _value.begin();
	 i != _value.end();
	 ++i)
    {
	//
	// Write name
	//

	Xdr::write <StreamIO> (os, i.name());

	//
	// Write Channel struct
	//

	Xdr::write <StreamIO> (os, int (i.channel().type));
	Xdr::pad   <StreamIO> (os, 4);
	Xdr::write <StreamIO> (os, i.channel().xSampling);
	Xdr::write <StreamIO> (os, i.channel().ySampling);
    }

    //
    // Write end of list marker
    //

    Xdr::write <StreamIO> (os, "");
}
开发者ID:Len3d,项目名称:appleseed,代码行数:29,代码来源:ImfChannelListAttribute.cpp


示例2: viewFromChannelName

ChannelList
channelsInView (const string & viewName,
	        const ChannelList & channelList,
		const StringVector & multiView)
{
    //
    // Return a list of all channels belonging to view viewName.
    //

    ChannelList q;

    for (ChannelList::ConstIterator i = channelList.begin();
	 i != channelList.end();
	 ++i)
    {
	//
	// Get view name for this channel
	//

	string view = viewFromChannelName (i.name(), multiView);


	//
	// Insert channel into q if it's a member of view viewName
	//

	if (view == viewName)
	   q.insert (i.name(), i.channel());
    }

    return q;
}
开发者ID:cathook,项目名称:rendering_final_proj,代码行数:32,代码来源:ImfMultiView.cpp


示例3: exrInfo

// Read the header of an EXR file.
// (ref) http://www.openexr.com/ReadingAndWritingImageFiles.pdf
int vtkOpenEXR::exrInfo(const char *fileName, std::vector<std::string> &channelNames)
{
  // parse filename
  QFileInfo fi(fileName);

  QString extension = fi.suffix().toLower();
  if ( extension.compare("exr") != 0 ) {
//    qDebug() << "the exr file was not found";
    return false;
  }

  if (!fi.exists())
  {
//    qDebug() << "the exr file was not found";
    return false;
  }

  int numChannels = 0;

  try {
    RgbaInputFile file(fileName);

    const ChannelList &ch = file.header().channels();

    int ic = 0;
    for (ChannelList::ConstIterator i = ch.begin(); i != ch.end(); ++i) {
      const Channel &channel = i.channel();
      const char* channelName = i.name(); // by Min
      PixelType type = channel.type;
      const char* t = (type == UINT) ? "uint" :
          ((type == HALF) ? "half" : "float");

      channelNames.push_back(channelName);
      ++ic;
//      qDebug() << "channel " << ic << ": " << t << ": " << channelName ;
    }
    numChannels = ic;
    const StringAttribute *comments =
    file.header().findTypedAttribute <StringAttribute> ("comments");

    const M44fAttribute *cameraTransform =
    file.header().findTypedAttribute <M44fAttribute> ("cameraTransform");

//    if (comments)
//       qDebug() << "comments\n   " << comments->value() ;

//    if (cameraTransform)
//       qDebug() << "cameraTransform\n" << cameraTransform->value() << flush;

  } catch (const std::exception &exc) {
//    qDebug() << exc.what();
    return false;
  }

  return numChannels; // number of channels
}
开发者ID:WeiqiJust,项目名称:CHER-Ob,代码行数:58,代码来源:vtkOpenEXR.cpp


示例4: channelNames

void EXRImageReader::channelNames( vector<string> &names )
{
	open( true );

	const ChannelList &channels = m_inputFile->header().channels();
	names.clear();
	for( ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i )
	{
		names.push_back( i.name() );
	}
}
开发者ID:Shockspot,项目名称:cortex,代码行数:11,代码来源:EXRImageReader.cpp


示例5: updateCombos

void EXRReaderPlugin::updateCombos()
{
	const std::string filename( getAbsoluteFirstFilename() );
	//TUTTLE_COUT("update Combo");
	if( bfs::exists( filename ) )
	{
		// read dims
		InputFile in( filename.c_str() );
		const Header& h  = in.header();
		const ChannelList& cl = h.channels();
		
		// Hide output channel selection till we don't select a channel.
		for( std::size_t i = 0; i < _vChannelChoice.size(); ++i )
		{
			//_vChannelChoice[i]->setIsSecret( true );
			_vChannelChoice[i]->resetOptions();
		}
		_vChannelNames.clear();
		for( ChannelList::ConstIterator it = cl.begin(); it != cl.end(); ++it )
		{
			_vChannelNames.push_back( it.name() );
			//TUTTLE_COUT_VAR( it.name() );
			for( std::size_t j = 0; j < _vChannelChoice.size(); ++j )
			{
				_vChannelChoice[j]->appendOption( it.name() );
			}
			++_channels;
			switch( _channels )
			{
				case 1:
				{
					for( std::size_t j = 0; j < _vChannelChoice.size(); j++ )
						_vChannelChoice.at(j)->setValue( 0 );
					break;
				}
				case 3:
				{
					for( std::size_t j = 0; j < _vChannelChoice.size() - 1; j++ )
						_vChannelChoice.at(j)->setValue( 2 - j );
					_vChannelChoice.at(3)->setValue( 0 );
					break;
				}
				case 4:
				{
					for( std::size_t j = 0; j < _vChannelChoice.size(); j++ )
						_vChannelChoice.at(j)->setValue( 3 - j );
					break;
				}
			}
		}
	}
}
开发者ID:DIT-Tools,项目名称:TuttleOFX,代码行数:52,代码来源:EXRReaderPlugin.cpp


示例6: pixelTypeSize

size_t
calculateBytesPerPixel (const Header &header)
{
    const ChannelList &channels = header.channels();

    size_t bytesPerPixel = 0;

    for (ChannelList::ConstIterator c = channels.begin();
	 c != channels.end();
	 ++c)
    {
	bytesPerPixel += pixelTypeSize (c.channel().type);
    }

    return bytesPerPixel;
}
开发者ID:voldemarz,项目名称:pbrt-v2,代码行数:16,代码来源:ImfTiledMisc.cpp


示例7: printPixelType

void
printChannelList (const ChannelList &cl)
{
    for (ChannelList::ConstIterator i = cl.begin(); i != cl.end(); ++i)
    {
        cout << "\n    " << i.name() << ", ";

        printPixelType (i.channel().type);

        cout << ", sampling " <<
        i.channel().xSampling << " " <<
        i.channel().ySampling;

        if (i.channel().pLinear)
            cout << ", plinear";
    }
}
开发者ID:GYingchao,项目名称:openexr,代码行数:17,代码来源:main.cpp


示例8: open

void EXRReader::open()
{
    // open file and read dimensions
    m_data.reset( new EXRReaderData(filename().c_str()) );

    int width  = m_data->dtw_.max.x - m_data->dtw_.min.x + 1;
    int height = m_data->dtw_.max.y - m_data->dtw_.min.y + 1;

    assert(width > 0);
    assert(height > 0);

    // check that file contains RGB data
    bool red = false;
    bool green = false;
    bool blue = false;
    const ChannelList &channels = m_data->file_.header().channels();
    for ( ChannelList::ConstIterator i = channels.begin(), iEnd = channels.end();
            i != iEnd; ++i )
    {
        if ( !strcmp(i.name(), "R") ) red = true;
        else if ( !strcmp(i.name(), "G") ) green = true;
        else if ( !strcmp(i.name(), "B") ) blue = true;
    }

    if ( !(red && green && blue) ) {
        throw pfs::io::InvalidHeader("OpenEXR file " + filename() + " does " \
                                     " not contain RGB data");
    }

    // check boundaries
    /*
    if ( (m_data->dtw_.min.x < m_data->dw_.min.x &&
          m_data->dtw_.max.x > m_data->dw_.max.x) ||
         (m_data->dtw_.min.y < m_data->dw_.min.y &&
          m_data->dtw_.max.y > m_data->dw_.max.y) )
    {
        throw pfs::io::InvalidHeader("No support for OpenEXR files DataWindow" \
                                     " greater than DisplayWindow" );
    }
    */

    setWidth(width);
    setHeight(height);
}
开发者ID:DINKIN,项目名称:LuminanceHDR,代码行数:44,代码来源:exrreader.cpp


示例9: prepareFrameBuffer

// Prepares a framebuffer for the requested channels, allocating also the
// appropriate Matlab memory
void vtkOpenEXR::prepareFrameBuffer(FrameBuffer & fb, const Box2i & dataWindow, const ChannelList & channels,
    const std::vector<std::string> & requestedChannels, std::vector< Array2D<float> *> & outData) // std::vector<mxArray *> & outMatlabData
{
    assert(!requestedChannels.empty());

    const Box2i & dw = dataWindow;
    const int width  = dw.max.x - dw.min.x + 1;
    const int height = dw.max.y - dw.min.y + 1;

    // The "weird" strides are because Matlab uses column-major order (check this out later)
//    const int xStride = height; // for matlab
//    const int yStride = 1;
    const int xStride = 1;
    const int yStride = width; // for c++

    // Offset for all the slices
    const off_t offset = - (dw.min.x * xStride + dw.min.y * yStride); // why negative?

    for (size_t i = 0; i != requestedChannels.size(); ++i) {
        // Allocate the memory
        //mxArray * data = mxCreateNumericMatrix(height, width, mxSINGLE_CLASS, mxREAL);
        Array2D<float> * data = new Array2D<float>;
        //Array2D<float> * data(height, width);
        data->resizeErase(height, width);

        outData[i] = data;

        float * ptr = static_cast<float*>(data[0][0]);  // check this out

        // Get the appropriate sampling factors
        int xSampling = 1, ySampling = 1;
        ChannelList::ConstIterator cIt = channels.find(requestedChannels[i].c_str());
        if (cIt != channels.end()) {
            xSampling = cIt.channel().xSampling;
            ySampling = cIt.channel().ySampling;
        }

        // Insert the slice in the framebuffer
        fb.insert(requestedChannels[i].c_str(), Slice(FLOAT, (char*)(ptr + offset), sizeof(float) * xStride, sizeof(float) * yStride, xSampling, ySampling));
    }
}
开发者ID:WeiqiJust,项目名称:CHER-Ob,代码行数:43,代码来源:vtkOpenEXR.cpp


示例10: IMB_exr_begin_read

/* read from file */
int IMB_exr_begin_read(void *handle, const char *filename, int *width, int *height)
{
	ExrHandle *data= (ExrHandle *)handle;
	
	if(BLI_exists(filename) && BLI_filepathsize(filename)>32) {	/* 32 is arbitrary, but zero length files crashes exr */
		data->ifile = new InputFile(filename);
		if(data->ifile) {
			Box2i dw = data->ifile->header().dataWindow();
			data->width= *width  = dw.max.x - dw.min.x + 1;
			data->height= *height = dw.max.y - dw.min.y + 1;
			
			const ChannelList &channels = data->ifile->header().channels();
			
			for (ChannelList::ConstIterator i = channels.begin(); i != channels.end(); ++i)
				IMB_exr_add_channel(data, NULL, i.name(), 0, 0, NULL);
			
			return 1;
		}
	}
	return 0;
}
开发者ID:rexbron,项目名称:blender-ocio,代码行数:22,代码来源:openexr_api.cpp


示例11: updateCombos

void EXRReaderPlugin::updateCombos()
{
	const std::string filepath( getAbsoluteFirstFilename() );
	if( ! bfs::exists( filepath ) )
		return;
	
	// read dims
	InputFile in( filepath.c_str() );
	const Header& h  = in.header();
	const ChannelList& cl = h.channels();

	_par = h.pixelAspectRatio();

	Imf::Compression compression = h.compression();
	
	switch( compression )
	{
		case RLE_COMPRESSION:
			_paramFileCompression->setValue( eParamCompression_RLE );
			break;
		case ZIPS_COMPRESSION:
			_paramFileCompression->setValue( eParamCompression_ZIPS );
			break;
		case ZIP_COMPRESSION:
			_paramFileCompression->setValue( eParamCompression_ZIP );
			break;
		case PIZ_COMPRESSION:
			_paramFileCompression->setValue( eParamCompression_PIZ );
			break;
		case PXR24_COMPRESSION:
			_paramFileCompression->setValue( eParamCompression_PXR24 );
			break;
		case B44_COMPRESSION:
			_paramFileCompression->setValue( eParamCompression_B44 );
			break;
		case B44A_COMPRESSION:
			_paramFileCompression->setValue( eParamCompression_B44A );
			break;
		case NO_COMPRESSION:
			_paramFileCompression->setValue( eParamCompression_None );
			break;
		default:
			_paramFileCompression->setValue( eParamCompression_None );
			TUTTLE_LOG_WARNING( "EXRReader: Unknown compression " << compression );
			break;
	}
	
	// Hide output channel selection till we don't select a channel.
	for( std::size_t i = 0; i < _paramsChannelChoice.size(); ++i )
	{
		//_vChannelChoice[i]->setIsSecret( true );
		_paramsChannelChoice[i]->resetOptions();
	}
	_channelNames.clear();
	for( ChannelList::ConstIterator it = cl.begin(); it != cl.end(); ++it )
	{
		_channelNames.push_back( it.name() );
		//TUTTLE_LOG_VAR( it.name() );
		for( std::size_t j = 0; j < _paramsChannelChoice.size(); ++j )
		{
			_paramsChannelChoice[j]->appendOption( it.name() );
		}
	}
	switch( _channelNames.size() )
	{
		case 1:
		{
			for( std::size_t j = 0; j < _paramsChannelChoice.size(); j++ )
				_paramsChannelChoice.at(j)->setValue( 0 );
			break;
		}
		case 3:
		{
			for( std::size_t j = 0; j < _paramsChannelChoice.size() - 1; j++ )
				_paramsChannelChoice.at(j)->setValue( 2 - j );
			_paramsChannelChoice.at(3)->setValue( 0 );
			break;
		}
		case 4:
		{
			for( std::size_t j = 0; j < _paramsChannelChoice.size(); j++ )
				_paramsChannelChoice.at(j)->setValue( 3 - j );
			break;
		}
	}
	
	const std::string& firstChannelName = _channelNames[ _paramsChannelChoice[0]->getValue() ];
	Imf::PixelType firstChannelType = cl.find(firstChannelName.c_str()).channel().type;
	switch( firstChannelType )
	{
		case Imf::UINT:
			_paramFileBitDepth->setValue( eTuttlePluginFileBitDepth32 );
			break;
		case Imf::HALF:
			_paramFileBitDepth->setValue( eTuttlePluginFileBitDepth16f );
			break;
		case Imf::FLOAT:
			_paramFileBitDepth->setValue( eTuttlePluginFileBitDepth32f );
			break;
		default:
//.........这里部分代码省略.........
开发者ID:edubois,项目名称:TuttleOFX,代码行数:101,代码来源:EXRReaderPlugin.cpp


示例12: lock

void	
ScanLineInputFile::setFrameBuffer (const FrameBuffer &frameBuffer)
{
    Lock lock (*_streamData);

    
    
    const ChannelList &channels = _data->header.channels();
    for (FrameBuffer::ConstIterator j = frameBuffer.begin();
	 j != frameBuffer.end();
	 ++j)
    {
	ChannelList::ConstIterator i = channels.find (j.name());

	if (i == channels.end())
	    continue;

	if (i.channel().xSampling != j.slice().xSampling ||
	    i.channel().ySampling != j.slice().ySampling)
	    THROW (IEX_NAMESPACE::ArgExc, "X and/or y subsampling factors "
				"of \"" << i.name() << "\" channel "
				"of input file \"" << fileName() << "\" are "
				"not compatible with the frame buffer's "
				"subsampling factors.");
    }

    //
    // Check if the new frame buffer descriptor is
    // compatible with the image file header.
    //
    
    
    if (!GLOBAL_SYSTEM_LITTLE_ENDIAN)
    {
        _data->optimizationMode._destination._format = OptimizationMode::PIXELFORMAT_OTHER;
        _data->optimizationMode._source._format      = OptimizationMode::PIXELFORMAT_OTHER;
    }
    else
    {
        StringVector * v=NULL;
        if(hasMultiView(_data->header))
        {
            v = &multiView(_data->header);
        }
        _data->optimizationMode = detectOptimizationMode(frameBuffer, channels,v);
    }
    
    // TODO-pk this disables optimization
    // _data->optimizationMode._destination._format = Imf::OptimizationMode::PIXELFORMAT_OTHER;
    

    //
    // Initialize the slice table for readPixels().
    //

    vector<InSliceInfo> slices;
    ChannelList::ConstIterator i = channels.begin();

    for (FrameBuffer::ConstIterator j = frameBuffer.begin();
	 j != frameBuffer.end();
	 ++j)
    {
	while (i != channels.end() && strcmp (i.name(), j.name()) < 0)
	{
	    //
	    // Channel i is present in the file but not
	    // in the frame buffer; data for channel i
	    // will be skipped during readPixels().
	    //

	    slices.push_back (InSliceInfo (i.channel().type,
					   i.channel().type,
					   0, // base
					   0, // xStride
					   0, // yStride
					   i.channel().xSampling,
					   i.channel().ySampling,
					   false,  // fill
					   true, // skip
					   0.0)); // fillValue
	    ++i;
	}

	bool fill = false;

	if (i == channels.end() || strcmp (i.name(), j.name()) > 0)
	{
	    //
	    // Channel i is present in the frame buffer, but not in the file.
	    // In the frame buffer, slice j will be filled with a default value.
	    //

	    fill = true;
	}

	slices.push_back (InSliceInfo (j.slice().type,
				       fill? j.slice().type:
				             i.channel().type,
				       j.slice().base,
				       j.slice().xStride,
//.........这里部分代码省略.........
开发者ID:JohanAberg,项目名称:openexr,代码行数:101,代码来源:ImfScanLineInputFile.cpp


示例13: mexFunction

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])
{
    char *exrFileName;
    double *mxData;
    int width = 0;
    int height = 0;
    int nSlices = 0;
    
    if (nrhs != 1 || !mxIsChar(prhs[0])) {
        mexErrMsgTxt("Usage: ReadMultichannelEXR('exrFile')\n");
    }
    
    // read the exr file with OpenEXR general interface
    exrFileName = mxArrayToString(prhs[0]);
    InputFile file (exrFileName);
    
    // query general file properties
    Box2i dw = file.header().dataWindow();
    width = dw.max.x - dw.min.x + 1;
    height = dw.max.y - dw.min.y + 1;
    
    const ChannelList &channels = file.header().channels();
    for (ChannelList::ConstIterator iter = channels.begin();
    iter != channels.end();
    ++iter) {
        nSlices++;
    }
    
    mexPrintf("Read \"%s\": width=%d height=%d nSlices=%d\n",
            exrFileName, width, height, nSlices);
    mxFree(exrFileName);
    
    // return a struct with info about image slices
    mwSize nDims = 2;
    mwSize infoDims[] = {1, 0};
    infoDims[1] = nSlices;
    const char* fieldNames[] = {"name", "pixelType",
    "xSampling", "ySampling", "isLinear"};
    int nFields = sizeof(fieldNames)/sizeof(fieldNames[0]);
    plhs[0] = mxCreateStructArray(nDims, infoDims, nFields, fieldNames);
    
    // return a double array with size [height width nSlices]
    nDims = 3;
    mwSize dataDims[] = {0, 0, 0};
    dataDims[0] = height;
    dataDims[1] = width;
    dataDims[2] = nSlices;
    plhs[1] = mxCreateNumericArray(nDims, dataDims, mxDOUBLE_CLASS, mxREAL);
    if (NULL == plhs[1]) {
        mexPrintf("Could not allocate image array of size [%d %d %d]\n",
                dataDims[0], dataDims[1], dataDims[2]);
        return;
    }
    double* data = mxGetPr(plhs[1]);
    
    // fill in info struct and data array
    int channelIndex = 0;
    for (ChannelList::ConstIterator iter = channels.begin(); iter != channels.end(); ++iter) {
        const Channel &channel = iter.channel();
        
        // fill in info struct for this channel
        mxSetField(plhs[0], channelIndex, "name", mxCreateString(iter.name()));
        mxSetField(plhs[0], channelIndex, "xSampling", mxCreateDoubleScalar((double)channel.xSampling));
        mxSetField(plhs[0], channelIndex, "ySampling", mxCreateDoubleScalar((double)channel.ySampling));
        mxSetField(plhs[0], channelIndex, "isLinear", mxCreateLogicalScalar((mxLogical)channel.pLinear));
        
        // fill in a slice of the data matrix for this channel
        //  memory allocation depends on slice pixel type
        mxArray* typeName = NULL;
        FrameBuffer frameBuffer;
        switch (channel.type) {
            case UINT:{
                typeName = mxCreateString("UINT");
                
                // copy slice data from file to a frame buffer
                Array2D<MATLAB_UINT32> slicePixels;
                slicePixels.resizeErase(height, width);
                frameBuffer.insert(iter.name(),
                        Slice(HALF,
                        (char *)(&slicePixels[0][0] - dw.min.x - dw.min.y * width),
                        sizeof(slicePixels[0][0]) * 1,
                        sizeof(slicePixels[0][0]) * width,
                        channel.xSampling,
                        channel.ySampling,
                        0.0));
                file.setFrameBuffer (frameBuffer);
                file.readPixels (dw.min.y, dw.max.y);
                
                // copy slice data from frame buffer to data array
                for (int i = 0; i < height; i++) {
                    for (int j = 0; j < width; j++) {
                        data[M3I(height, width, i, j, channelIndex)] = slicePixels[i][j];
                    }
                }
                
                break;
            }
            
            case HALF:{
                typeName = mxCreateString("HALF");
//.........这里部分代码省略.........
开发者ID:RenderToolbox3,项目名称:RenderToolbox3,代码行数:101,代码来源:ReadMultichannelEXR.cpp


示例14: lock

void	
OutputFile::setFrameBuffer (const FrameBuffer &frameBuffer)
{
    Lock lock (*_data);
    
    //
    // Check if the new frame buffer descriptor
    // is compatible with the image file header.
    //

    const ChannelList &channels = _data->header.channels();

    for (ChannelList::ConstIterator i = channels.begin();
	 i != channels.end();
	 ++i)
    {
	FrameBuffer::ConstIterator j = frameBuffer.find (i.name());

	if (j == frameBuffer.end())
	    continue;

	if (i.channel().type != j.slice().type)
	{
	    THROW (Iex::ArgExc, "Pixel type of \"" << i.name() << "\" channel "
			        "of output file \"" << fileName() << "\" is "
			        "not compatible with the frame buffer's "
			        "pixel type.");
	}

	if (i.channel().xSampling != j.slice().xSampling ||
	    i.channel().ySampling != j.slice().ySampling)
	{
	    THROW (Iex::ArgExc, "X and/or y subsampling factors "
				"of \"" << i.name() << "\" channel "
				"of output file \"" << fileName() << "\" are "
				"not compatible with the frame buffer's "
				"subsampling factors.");
	}
    }
    
    //
    // Initialize slice table for writePixels().
    //

    vector<OutSliceInfo> slices;

    for (ChannelList::ConstIterator i = channels.begin();
	 i != channels.end();
	 ++i)
    {
	FrameBuffer::ConstIterator j = frameBuffer.find (i.name());

	if (j == frameBuffer.end())
	{
	    //
	    // Channel i is not present in the frame buffer.
	    // In the file, channel i will contain only zeroes.
	    //

	    slices.push_back (OutSliceInfo (i.channel().type,
					    0, // base
					    0, // xStride,
					    0, // yStride,
					    i.channel().xSampling,
					    i.channel().ySampling,
					    true)); // zero
	}
	else
	{
	    //
	    // Channel i is present in the frame buffer.
	    //

	    slices.push_back (OutSliceInfo (j.slice().type,
					    j.slice().base,
					    j.slice().xStride,
					    j.slice().yStride,
					    j.slice().xSampling,
					    j.slice().ySampling,
					    false)); // zero
	}
    }

    //
    // Store the new frame buffer.
    //

    _data->frameBuffer = frameBuffer;
    _data->slices = slices;
}
开发者ID:ezhangle,项目名称:CxlCommon,代码行数:90,代码来源:ImfOutputFile.cpp


示例15: ArgExc


//.........这里部分代码省略.........
        
    }

    //
    // The compression method must be one of the predefined values.
    //

    if (!isValidCompression (this->compression()))
  	throw IEX_NAMESPACE::ArgExc ("Unknown compression type in image header.");
    
    if(isDeepData(part_type))
    {
        if (!isValidDeepCompression (this->compression()))
            throw IEX_NAMESPACE::ArgExc ("Compression type in header not valid for deep data");
    }

    //
    // Check the channel list:
    //
    // If the file is tiled then for each channel, the type must be one of the
    // predefined values, and the x and y sampling must both be 1.
    //
    // If the file is not tiled then for each channel, the type must be one
    // of the predefined values, the x and y coordinates of the data window's
    // upper left corner must be divisible by the x and y subsampling factors,
    // and the width and height of the data window must be divisible by the
    // x and y subsampling factors.
    //

    const ChannelList &channels = this->channels();
    
    if (isTiled)
    {
	for (ChannelList::ConstIterator i = channels.begin();
	     i != channels.end();
	     ++i)
	{
	    if (i.channel().type != UINT &&
		i.channel().type != HALF &&
		i.channel().type != FLOAT)
	    {
		THROW (IEX_NAMESPACE::ArgExc, "Pixel type of \"" << i.name() << "\" "
			            "image channel is invalid.");
	    }

	    if (i.channel().xSampling != 1)
	    {
		THROW (IEX_NAMESPACE::ArgExc, "The x subsampling factor for the "
				    "\"" << i.name() << "\" channel "
				    "is not 1.");
	    }	

	    if (i.channel().ySampling != 1)
	    {
		THROW (IEX_NAMESPACE::ArgExc, "The y subsampling factor for the "
				    "\"" << i.name() << "\" channel "
				    "is not 1.");
	    }	
	}
    }
    else
    {
	for (ChannelList::ConstIterator i = channels.begin();
	     i != channels.end();
	     ++i)
	{
开发者ID:GerHobbelt,项目名称:openexr,代码行数:67,代码来源:ImfHeader.cpp


示例16: lock

void	
ScanLineInputFile::setFrameBuffer (const FrameBuffer &frameBuffer)
{
    Lock lock (*_streamData);

    
    
    const ChannelList &channels = _data->header.channels();
    for (FrameBuffer::ConstIterator j = frameBuffer.begin();
	 j != frameBuffer.end();
	 ++j)
    {
	ChannelList::ConstIterator i = channels.find (j.name());

	if (i == channels.end())
	    continue;

	if (i.channel().xSampling != j.slice().xSampling ||
	    i.channel().ySampling != j.slice().ySampling)
	    THROW (IEX_NAMESPACE::ArgExc, "X and/or y subsampling factors "
				"of \"" << i.name() << "\" channel "
				"of input file \"" << fileName() << "\" are "
				"not compatible with the frame buffer's "
				"subsampling factors.");
    }

    // optimization is possible if this is a little endian system
    // and both inputs and outputs are half floats
    // 
    bool optimizationPossible = true;
    
    if (!GLOBAL_SYSTEM_LITTLE_ENDIAN)
    {
        optimizationPossible =false;
    }
    
    vector<sliceOptimizationData> optData;
    

    //
    // Initialize the slice table for readPixels().
    //

    vector<InSliceInfo> slices;
    ChannelList::ConstIterator i = channels.begin();
    
    // current offset of channel: pixel data starts at offset*width into the
    // decompressed scanline buffer
    size_t offset = 0;
    
    for (FrameBuffer::ConstIterator j = frameBuffer.begin();
	 j != frameBuffer.end();
	 ++j)
    {
	while (i != channels.end() && strcmp (i.name(), j.name()) < 0)
	{
	    //
	    // Channel i is present in the file but not
	    // in the frame buffer; data for channel i
	    // will be skipped during readPixels().
	    //

	    slices.push_back (InSliceInfo (i.channel().type,
					   i.channel().type,
					   0, // base
					   0, // xStride
					   0, // yStride
					   i.channel().xSampling,
					   i.channel().ySampling,
					   false,  // fill
					   true, // skip
					   0.0)); // fillValue
	    
              switch(i.channel().type)
              {
                  case OPENEXR_IMF_INTERNAL_NAMESPACE::HALF :
                      offset++;
                      break;
                  case OPENEXR_IMF_INTERNAL_NAMESPACE::FLOAT :
                      offset+=2;
                      break;
                  case OPENEXR_IMF_INTERNAL_NAMESPACE::UINT :
                      offset+=2;
                      break;
              }
              ++i;
	}

	bool fill = false;

	if (i == channels.end() || strcmp (i.name(), j.name()) > 0)
	{
	    //
	    // Channel i is present in the frame buffer, but not in the file.
	    // In the frame buffer, slice j will be filled with a default value.
	    //

	    fill = true;
	}

//.........这里部分代码省略.........
开发者ID:Ericson2314,项目名称:openexr,代码行数:101,代码来源:ImfScanLineInputFile.cpp


示例17: lock

void
DeepScanLineOutputFile::setFrameBuffer (const DeepFrameBuffer &frameBuffer)
{
    Lock lock (*_data->_streamData);

    //
    // Check if the new frame buffer descriptor
    // is compatible with the image file header.
    //

    const ChannelList &channels = _data->header.channels();

    for (ChannelList::ConstIterator i = channels.begin();
            i != channels.end();
            ++i)
    {
        DeepFrameBuffer::ConstIterator j = frameBuffer.find (i.name());

        if (j == frameBuffer.end())
            continue;

        if (i.channel().type != j.slice().type)
        {
            THROW (IEX_NAMESPACE::ArgExc, "Pixel type of \"" << i.name() << "\" channel "
                   "of output file \"" << fileName() << "\" is "
                   "not compatible with the frame buffer's "
                   "pixel type.");
        }

        if (i.channel().xSampling != j.slice().xSampling ||
                i.channel().ySampling != j.slice().ySampling)
        {
            THROW (IEX_NAMESPACE::ArgExc, "X and/or y subsampling factors "
                   "of \"" << i.name() << "\" channel "
                   "of output file \"" << fileName() << "\" are "
                   "not compatible with the frame buffer's "
                   "subsampling factors.");
        }
    }

    //
    // Store the pixel sample count table.
    // (TODO) Support for different sampling rates?
    //

    const Slice& sampleCountSlice = frameBuffer.getSampleCountSlice();
    if (sampleCountSlice.base == 0)
    {
        throw IEX_NAMESPACE::ArgExc ("Invalid base pointer, please set a proper sample count slice.");
    }
    else
    {
        _data->sampleCountSliceBase = sampleCountSlice.base;
        _data->sampleCountXStride = sampleCountSlice.xStride;
        _data->sampleCountYStride = sampleCountSlice.yStride;
    }

    //
    // Initialize slice table for writePixels().
    // Pixel sample count slice is not presented in the header,
    // so it wouldn't be added here.
    // Store the pixel base pointer table.
    // (TODO) Support for different sampling rates?
    //

    vector<OutSliceInfo*> slices;

    for (ChannelList::ConstIterator i = channels.begin();
            i != channels.end();
            ++i)
    {
        DeepFrameBuffer::ConstIterator j = frameBuffer.find (i.name());

        if (j == frameBuffer.end())
        {
            //
            // Channel i is not present in the frame buffer.
            // In the file, channel i will contain only zeroes.
            //

            slices.push_back (new OutSliceInfo (i.channel().type,
                                                NULL,// base
                                                0,// sampleStride,
                                                0,// xStride
                                                0,// yStride
                                                i.channel().xSampling,
                                                i.channel().ySampling,
                                                true)); // zero
        }
        else
        {
            //
            // Channel i is present in the frame buffer.
            //

            slices.push_back (new OutSliceInfo (j.slice().type,
                                                j.slice().base,
                                                j.slice().sampleStride,
                                                j.slice().xStride,
                                                j.slice().yStride,
//.........这里部分代码省略.........
开发者ID:epu,项目名称:openexr,代码行数:101,代码来源:ImfDeepScanLineOutputFile.cpp


示例18: lock

void	
TiledOutputFile::setFrameBuffer (const FrameBuffer &frameBuffer)
{
    Lock lock (*_streamData);

    //
    // Check if the new frame buffer descriptor
    // is compatible with the image file header.
    //

    const ChannelList &channels = _data->header.channels();

    for (ChannelList::ConstIterator i = channels.begin();
	 i != channels.end();
	 ++i)
    {
	FrameBuffer::ConstIterator j = frameBuffer.find (i.name());

	if (j == frameBuffer.end())
	    continue;

	if (i.channel().type != j.slice().type)
	    THROW (IEX_NAMESPACE::ArgExc, "Pixel type of \"" << i.name() << "\" channel "
				"of output file \"" << fileName() << "\" is "
				"not compatible with the frame buffer's "
				"pixel type.");

	if (j.slice().xSampling != 1 || j.slice().ySampling != 1)
	    THROW (IEX_NAMESPACE::ArgExc, "All channels in a tiled file must have"
				"sampling (1,1).");
    }
    
    //
    // Initialize slice table for writePixels().
    //

    vector<TOutSliceInfo> slices;

    for (ChannelList::ConstIterator i = channels.begin();
	 i != channels.end();
	 ++i)
    {
	FrameBuffer::ConstIterator j = frameBuffer.find (i.name());

	if (j == frameBuffer.end())
	{
	    //
	    // Channel i is not present in the frame buffer.
	    // In the file, channel i will contain only zeroes.
	    //

	    slices.push_back (TOutSliceInfo (i.channel().type,
					     0, // base
					     0, // xStride,
					     0, // yStride,
					     true)); // zero
	}
	else
	{
	    //
	    // Channel i is present in the frame buffer.
	    //

	    slices.push_back (TOutSliceInfo (j.slice().type,
					     j.slice().base,
					     j.slice().xStride,
					     j.slice().yStride,
					     false, // zero
                                             (j.slice().xTileCoords)? 1: 0,
                                             (j.slice().yTileCoords)? 1: 0));
	}
    }

    //
    // Store the new frame buffer.
    //

    _data->frameBuffer = frameBuffer;
    _data->slices = slices;
}
开发者ID:Kurvivor19,项目名称:FreeImage,代码行数:80,代码来源:ImfTiledOutputFile.cpp


示例19: 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);
//.........这里部分代码省略.........
开发者ID:GYingchao,项目名称:openexr,代码行数:101,代码来源:makeMultiView.cpp


示例20: lock

void	
ScanLineInputFile::setFrameBuffer (const FrameBuffer &frameBuffer)
{
    Lock lock (*_data);

    //
    // Check if the new frame buffer descriptor is
    // compatible with the image file header.
    //

    const ChannelList &channels = _data->header.channels();

    for (FrameBuffer::ConstIterator j = frameBuffer.begin();
	 j != frameBuffer.end();
	 ++j)
    {
	ChannelList::ConstIterator i = channels.find (j.name());

	if (i == channels.end())
	    continue;

	if (i.channel().xSampling != j.slice().xSampling ||
	    i.channel().ySampling != j.slice().ySampling)
	    THROW (Iex::ArgExc, "X and/or y subsampling factors "
				"of \"" << i.name() << "\" channel "
				"of input file \"" << fileName() << "\" are "
				"not compatible with the frame buffer's "
				"subsampling factors.");
    }

    //
    // Initialize the slice table for readPixels().
    //

    vector<InSliceInfo> slices;
    ChannelList::ConstIterator 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ chanserv::Channel类代码示例发布时间:2022-05-31
下一篇:
C++ channel::shared_pointer类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap