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


C++ ConstIterator::channel方法代码示例

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


在下文中一共展示了ConstIterator::channel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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 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,
				       j.slice().yStride,
				       j.slice().xSampling,
				       j.slice().ySampling,
				       fill,
				       false, // skip
				       j.slice().fillValue));

	if (i != channels.end() && !fill)
	    ++i;
    }

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

    _data->frameBuffer = frameBuffer;
    _data->slices = slices;
}
开发者ID:Drknss,项目名称:Game,代码行数:97,代码来源:ImfScanLineInputFile.cpp

示例9: 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

示例10: 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

示例11: 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

示例12: ArgExc


//.........这里部分代码省略.........
        if (lineOrder != INCREASING_Y &&
            lineOrder != DECREASING_Y)
            throw IEX_NAMESPACE::ArgExc ("Invalid line order in image header.");
        
        
    }

    //
    // 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
    {
开发者ID:GerHobbelt,项目名称:openexr,代码行数:67,代码来源:ImfHeader.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	
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

示例15: 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


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