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


C++ InStream::Close方法代码示例

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


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

示例1: init

 /// Reset everything to initial state
 ///
 void init () {
     if (m_stream) {
         m_stream->Close ();
         delete m_stream;
         m_stream = NULL;
     }
     m_userBuf.clear ();
 }
开发者ID:StereoD-Development,项目名称:oiio,代码行数:10,代码来源:cineoninput.cpp

示例2: InStream

OIIO_PLUGIN_EXPORTS_END



bool
DPXInput::valid_file (const std::string &filename) const
{
    InStream *stream = new InStream();
    if (! stream)
        return false;
    bool ok = false;
    if (stream->Open(filename.c_str())) {
        dpx::Reader dpx;
        dpx.SetInStream(stream);
        ok = dpx.ReadHeader();
        stream->Close();
    }
    delete stream;
    return ok;
}
开发者ID:Chifoncake,项目名称:oiio,代码行数:20,代码来源:dpxinput.cpp

示例3: main


//.........这里部分代码省略.........
		Usage();
		return 1;
	}

	// open the image
	InStream img;
	if (!img.Open(argv[offset]))
	{
		cout << "Unable to open file " << argv[1] << endl;
		return 1;
	}
	
	dpx::Reader dpx;
	dpx.SetInStream(&img);
	if (!dpx.ReadHeader())
	{
		cout << "Unable to read header" << endl;
		return 2;
	}
	
	TIFF *out;
	out = TIFFOpen(argv[offset+1], "w");
	if (out == NULL)
	{
		cout << "Unable to open output file" << endl;
		return 3;
	}

	// data size, override if user specifies
	dpx::DataSize size = dpx.header.ComponentDataSize(0);
	int nob = dpx.header.ComponentByteCount(0);
	if (write8bit)
	{
		size = dpx::kByte;
		nob = 1;
	}

	cout << "Image Width " << dpx.header.Width() << " Height " << 
			dpx.header.Height() << " component byte count " << 
			dpx.header.ComponentByteCount(0) << endl;
	
	// conversion
	int format = PHOTOMETRIC_RGB;
	int elementCount = 3;
	if (dpx.header.ImageElementComponentCount(0) == 1) {
		format = PHOTOMETRIC_MINISBLACK;
		elementCount = 1;
	}

	TIFFSetField(out, TIFFTAG_IMAGEWIDTH, (uint32) dpx.header.Width());
	TIFFSetField(out, TIFFTAG_IMAGELENGTH, (uint32) dpx.header.Height());
	TIFFSetField(out, TIFFTAG_BITSPERSAMPLE, (uint32) nob * 8);
	TIFFSetField(out, TIFFTAG_SAMPLESPERPIXEL, elementCount);
	TIFFSetField(out, TIFFTAG_COMPRESSION, COMPRESSION_NONE);
	TIFFSetField(out, TIFFTAG_ORIENTATION, ORIENTATION_TOPLEFT);
	TIFFSetField(out, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
	TIFFSetField(out, TIFFTAG_PHOTOMETRIC, format);
	TIFFSetField(out, TIFFTAG_MINSAMPLEVALUE, 0);
	int max = 0xff;
	if (nob == 2)
		max = 0xffff;
	else
		max = 0xffffffff;
	TIFFSetField(out, TIFFTAG_MAXSAMPLEVALUE, max);
	
	tdata_t buf = _TIFFmalloc(TIFFScanlineSize(out));
	if (buf == NULL) 
	{
		cout << "memory allocation error" << endl;
		return 4;
	}

	Block block(0, 0, dpx.header.Width()-1, 0);
	int y;
	for (y = 0; y < dpx.header.Height(); y++)
	{
		block.y1 = y;
		block.y2 = y;
			
		if (dpx.ReadBlock(buf, size, block, dpx.header.ImageDescriptor(0)) == false)
		{
			cout << "unable to read line " << y << " with component data size " << size << endl;
			return 5;
		}

		if (TIFFWriteScanline(out, buf, y, 0) < 0)
		{
			cout << "unable to write tiff scanline " << y << endl;
			return 6;
		}
	}


	_TIFFfree(buf);
	
	img.Close();
	TIFFClose(out);
	
	return 0;
}
开发者ID:MOXfiles,项目名称:dpx,代码行数:101,代码来源:dpx2tiff.cpp


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