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


C++ OutputFile类代码示例

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


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

示例1: main

int main(int argc, char **argv) 
{
  setOptions(argc, argv);
  showOptions();

  SpecificationFile sFile(modelFile);
  SUT *sut = new SUT(sFile.parameter, sFile.value, sFile.tway);

  if (constraintFile != "") {
    ConstraintFile cFile(constraintFile);
    sut->setConstraint(cFile.getClauses());
  }

  Framework* generator = initGenerator(algorithm, sut);

  srand((unsigned int)time(0));
  OutputFile outFile;
  for( int i = 0 ; i < repeat ; i++ ) {
    generator->PSOEvolve();
    outFile.update(generator->ARRAY, sut->parameter, generator->TIME);
  }
  outFile.write(sut, outputFile);
  cout << "Best Size = " << outFile.size << " Time = " << outFile.time << endl;

	return 0;
}
开发者ID:waynedd,项目名称:DPSO,代码行数:26,代码来源:main.cpp

示例2: imb_save_openexr_float

static int imb_save_openexr_float(struct ImBuf *ibuf, const char *name, int flags)
{
	int channels = ibuf->channels;
	int width = ibuf->x;
	int height = ibuf->y;
	int write_zbuf = (flags & IB_zbuffloat) && ibuf->zbuf_float != NULL;   // summarize

	try
	{
		Header header (width, height);
		
		openexr_header_compression(&header, ibuf->ftype & OPENEXR_COMPRESS);
		openexr_header_metadata(&header, ibuf);
		
		header.channels().insert ("R", Channel (FLOAT));
		header.channels().insert ("G", Channel (FLOAT));
		header.channels().insert ("B", Channel (FLOAT));
		if (ibuf->depth==32 && channels >= 4)
			header.channels().insert ("A", Channel (FLOAT));
		if (write_zbuf)
			header.channels().insert ("Z", Channel (FLOAT));
		
		FrameBuffer frameBuffer;			
		OutputFile *file = new OutputFile(name, header);			
		int xstride = sizeof(float) * channels;
		int ystride = - xstride*width;
		float *rect[4] = {NULL, NULL, NULL, NULL};

		/* last scanline, stride negative */
		rect[0]= ibuf->rect_float + channels*(height-1)*width;
		rect[1]= rect[0]+1;
		rect[2]= rect[0]+2;
		rect[3]= (channels >= 4)? rect[0]+3:rect[0]; /* red as alpha, is this needed since alpha isnt written? */

		frameBuffer.insert ("R", Slice (FLOAT,  (char *)rect[0], xstride, ystride));
		frameBuffer.insert ("G", Slice (FLOAT,  (char *)rect[1], xstride, ystride));
		frameBuffer.insert ("B", Slice (FLOAT,  (char *)rect[2], xstride, ystride));
		if (ibuf->depth==32 && channels >= 4)
			frameBuffer.insert ("A", Slice (FLOAT,  (char *)rect[3], xstride, ystride));
		if (write_zbuf)
			frameBuffer.insert ("Z", Slice (FLOAT, (char *) (ibuf->zbuf_float + (height-1)*width),
											sizeof(float), sizeof(float) * -width));
		file->setFrameBuffer (frameBuffer);				  
		file->writePixels (height);					  
		delete file;
	}
	catch (const std::exception &exc)
	{      
		printf("OpenEXR-save: ERROR: %s\n", exc.what());
		if (ibuf) IMB_freeImBuf(ibuf);
		
		return (0);
	}
	
	return (1);
	//	printf("OpenEXR-save: Done.\n");
}
开发者ID:rexbron,项目名称:blender-ocio,代码行数:57,代码来源:openexr_api.cpp

示例3: store

bool HashSet::store( ) const
{
   OutputFile out;

   for ( const auto &id : _set )
      id.store( out );

   return out.rename( path_get( PathType::OBJ, "index" ).string( ) );
}
开发者ID:xxwpc,项目名称:gitbk,代码行数:9,代码来源:HashSet.cpp

示例4: write_to_exr_file

	void write_to_exr_file (const string& file_name_) {
		Header header (m_x_res, m_y_res);
		
		//edit the active zone.
		Box2i data_window (V2i (0, 0),
						   V2i (m_x_res - 1, m_y_res - 1));

		header.dataWindow() = data_window; //beuark.

		header.channels().insert ("R", Channel (HALF));
		header.channels().insert ("G", Channel (HALF));
		header.channels().insert ("B", Channel (HALF));	
	
		const int x_count = m_x_res;
		const int nb_pixels = m_x_res * m_y_res;
	
		half * half_rgb = new half[3 * nb_pixels];	
	
		int offset = 0;
		int num_pixel = 0;
	
		for (int y = 0; y < m_y_res; y++) {
			for (int x = 0; x < m_x_res; x++, num_pixel++) {
				Color color = pixel (x, y);
			
				for (int i = 0; i < 3; i++, offset++) {
					half_rgb[offset] = color[i];
				}			
			}
		}
	
		offset = 0;
	
		half_rgb -= 3 * offset;	

		FrameBuffer fb;
		//there are 3 * sizeof(half) bytes between two R elements.
		fb.insert ("R", Slice (HALF, (char *)half_rgb, 3 * sizeof (half),
							   3 * x_count * sizeof (half)));
		//the first element of G is sizeof(half) after the first element of R.
		fb.insert ("G", Slice (HALF, (char *)half_rgb + sizeof(half), 3 * sizeof (half),
							   3 * x_count * sizeof (half)));
		//the first B element is 2 * sizeof (half) bytes after the first element of R.
		fb.insert ("B", Slice (HALF, (char *)half_rgb + 2 * sizeof(half), 3 * sizeof (half),
							   3 * x_count * sizeof (half)));
		try {
			OutputFile file (file_name_.c_str(), header);
			file.setFrameBuffer (fb);
			//y_count() rows to write
			file.writePixels (m_y_res);
		} catch (const std::exception &e) {
			std::cerr<<"Unable to write image file "<<file_name_<<" : "<<e.what()<<std::endl;
		}

		//release the memory, but come back to the real address before.
		delete[] (half_rgb + 3 * offset);	
	}
开发者ID:Chinmay-at-git,项目名称:M1UPS,代码行数:57,代码来源:image.hpp

示例5: saveEXRRGBA

void saveEXRRGBA(const char* filename, int width, int height, float* data)
{
	half *idr_r = new half[ width * height];
	half *idr_g = new half[ width * height];
	half *idr_b = new half[ width * height];
	half *idr_a = new half[ width * height];
	
	for(int j=0; j< height; j++) {
		int invj = height - 1 -j;
		for(int i=0; i< width; i++) {
			idr_r[j* width + i] = (half)data[(invj* width + i)*4];
			idr_g[j* width + i] = (half)data[(invj* width + i)*4+1];
			idr_b[j* width + i] = (half)data[(invj* width + i)*4+2];
			idr_a[j* width + i] = (half)data[(invj* width + i)*4+3];
		}
	}
// write exr
	Header idrheader ( width,  height); 

		idrheader.channels().insert ("R", Channel (HALF));
		idrheader.channels().insert ("G", Channel (HALF));                                   // 1 
        idrheader.channels().insert ("B", Channel (HALF));
		idrheader.channels().insert ("A", Channel (HALF));                   // 2  
    
        OutputFile idrfile (filename, idrheader);                               // 4 
        FrameBuffer idrframeBuffer;
		 idrframeBuffer.insert ("R",                                // name   // 6 
                            Slice (HALF,                        // type   // 7 
                                   (char *) idr_r,            // base   // 8 
                                   sizeof (*idr_r) * 1,       // xStride// 9 
                                   sizeof (*idr_r) *  width));
        idrframeBuffer.insert ("G",                                // name   // 6 
                            Slice (HALF,                        // type   // 7 
                                   (char *) idr_g,            // base   // 8 
                                   sizeof (*idr_g) * 1,       // xStride// 9 
                                   sizeof (*idr_g) *  width));
		 idrframeBuffer.insert ("B",                                // name   // 6 
                            Slice (HALF,                        // type   // 7 
                                   (char *) idr_b,            // base   // 8 
                                   sizeof (*idr_b) * 1,       // xStride// 9 
                                   sizeof (*idr_b) *  width));
		 idrframeBuffer.insert ("A",                                // name   // 6 
                            Slice (HALF,                        // type   // 7 
                                   (char *) idr_a,            // base   // 8 
                                   sizeof (*idr_a) * 1,       // xStride// 9 
                                   sizeof (*idr_a) *  width));
       
        idrfile.setFrameBuffer (idrframeBuffer);                                // 16 
        idrfile.writePixels ( height); 
        
// cleanup
	delete[] idr_r;
	delete[] idr_g;
	delete[] idr_b;
	delete[] idr_a;
}
开发者ID:spinos,项目名称:fungi,代码行数:56,代码来源:image.cpp

示例6: while

EStatusCode PreprocessorTest::RunTest(const string& inName, const string& inOriginalFile, const string& inOutputFile, const string& inComparisonFile)
{
	EStatusCode status = eSuccess;

	StringToStringMap preprocessorDefinitions;
	StringList includeFolders;

	includeFolders.push_back(scSamplesBasePath);
	preprocessorDefinitions.insert(StringToStringMap::value_type("PREDEFINED_SYMBOL","2"));

	InputFile sourceFile;
	sourceFile.OpenFile(inOriginalFile);

	OutputFile outputFile;
	outputFile.OpenFile(inOutputFile);
	mCurrentStream = outputFile.GetOutputStream();

	PreProcessor preProcessor;

	preProcessor.Setup(sourceFile.GetInputStream(),inOriginalFile,preprocessorDefinitions,includeFolders);

	preProcessor.AddListener(this);

	mStartRow = true;
	BoolAndString tokenizerResult = preProcessor.GetNextToken();
	while(tokenizerResult.first)
	{
		if(!mStartRow)
			mCurrentStream->Write((const Byte*)"  ",2); // 2 spaces, so we can clearly distinct tokens
		mCurrentStream->Write((const Byte*)tokenizerResult.second.c_str(),tokenizerResult.second.size());

		mStartRow = false;

		tokenizerResult = preProcessor.GetNextToken();
	}

	sourceFile.CloseFile();
	outputFile.CloseFile();

	mCurrentStream = NULL;
	
	SimpleFileComparer comparer;

	if(!comparer.Same(inOutputFile,inComparisonFile))
	{
		cout<<"TokenizerTest::Run, failed in test named "<<inName<<". see result in "<<inOutputFile<<" and compare with the required result in "<<inComparisonFile<<"\n";
		status = eFailure;
	}

	return status;	

}
开发者ID:galkahana,项目名称:Code-Name-Falafel,代码行数:52,代码来源:PreprocessorTest.cpp

示例7: new

OutputFile *OutputFile::CreateTemporary(const std::string &pFileTemplate,
                                        unsigned pFlags) {
    char *tmp_filename = NULL;
    int tmp_fd;
    OutputFile *result = NULL;

    // Allocate memory to hold the generated unique temporary filename.
    tmp_filename =
        new (std::nothrow) char [ pFileTemplate.length() + /* .XXXXXX */7 + 1 ];
    if (tmp_filename == NULL) {
        ALOGE("Out of memory when allocates memory for filename %s in "
              "OutputFile::CreateTemporary()!", pFileTemplate.c_str());
        return NULL;
    }

    // Construct filename template for mkstemp().
    if (pFileTemplate.length() > 0)
        ::memcpy(tmp_filename, pFileTemplate.c_str(), pFileTemplate.length());
    ::strncpy(tmp_filename + pFileTemplate.length(), ".XXXXXX", 7);

    // POSIX mkstemp() never returns EINTR.
    tmp_fd = ::mkstemp(tmp_filename);
    if (tmp_fd < 0) {
        llvm::error_code err(errno, llvm::posix_category());
        ALOGE("Failed to create temporary file using mkstemp() for %s! (%s)",
              tmp_filename, err.message().c_str());
        delete [] tmp_filename;
        return NULL;
    }

    // Create result OutputFile. Temporary file is always truncated.
    result = new (std::nothrow) OutputFile(tmp_filename,
                                           pFlags | FileBase::kTruncate);
    if (result == NULL) {
        ALOGE("Out of memory when creates OutputFile for %s!", tmp_filename);
        // Fall through to the clean-up codes.
    } else {
        if (result->hasError()) {
            ALOGE("Failed to open temporary output file %s! (%s)",
                  result->getName().c_str(), result->getErrorMessage().c_str());
            delete result;
            result = NULL;
            // Fall through to the clean-up codes.
        }
    }

    // Clean up.
    delete [] tmp_filename;
    ::close(tmp_fd);

    return result;
}
开发者ID:Proshivalskiy,项目名称:MT6582_kernel_source,代码行数:52,代码来源:OutputFile.cpp

示例8: writeEXRHalf

void writeEXRHalf(OStream *ost, const float *pixels,
	      int width, int height, int components) 
{
	//assert(components==3 || components==4);
	// TODO: throw std::exception if invalid number of components

	Header header (width, height);
	header.channels().insert ("R", Channel (HALF));
	header.channels().insert ("G", Channel (HALF));
	header.channels().insert ("B", Channel (HALF));
	if(components==4)
		header.channels().insert ("A", Channel (HALF));

	// Convert data to half
	half *data = new half [width*height*components];
	
	std::copy(pixels, pixels+(width*height*components), data);
	
	// And save it
	OutputFile file (*ost, header);
	FrameBuffer frameBuffer;

	frameBuffer.insert("R",				// name
			    Slice (HALF,		// type
				   ((char *) data)+0,	// base
				   2 * components,		// xStride
				   2 * components * width));	// yStride
	frameBuffer.insert("G",				// name
			    Slice (HALF,		// type
				   ((char *) data)+2,	// base
				   2 * components,		// xStride
				   2 * components * width));	// yStride
	frameBuffer.insert("B",				// name
			    Slice (HALF,		// type
				   ((char *) data)+4,	// base
				   2 * components,		// xStride
				   2 * components * width));	// yStride
	if(components==4) {
		frameBuffer.insert("A",					// name
				    Slice (HALF,			// type
					   ((char *) data)+6,		// base
					   2 * components,		// xStride
					   2 * components * width));	// yStride
	}

	file.setFrameBuffer(frameBuffer);
	file.writePixels(height);
	delete data;
}
开发者ID:JoeyZh,项目名称:ogre-android,代码行数:49,代码来源:OgreEXRCodec.cpp

示例9: saveEXRFile

////////////////////////////////////////////////////////////////////////////////
// Saves an EXR file from Array<Rgba> data.
////////////////////////////////////////////////////////////////////////////////
static bool saveEXRFile (const char *filename, 
                          const int width, 
                          const int height, 
                          Array<Rgba>* imageData) 
{

  if (filename == NULL || imageData == NULL || width <= 0 || height <= 0) {
    printf("Cannot write EXR file: invalid filename or image data.\n");
    return false;
  }

  // prepare header
  Header header (width, height);
  header.channels().insert ("R", Channel (HALF));
  header.channels().insert ("G", Channel (HALF));
  header.channels().insert ("B", Channel (HALF));

  // create file
  OutputFile exrFile (filename, header);

  // insert frame buffer
  FrameBuffer frameBuffer;
  frameBuffer.insert ("R",									// name
    Slice (HALF,														// type
    (char *) &(((Rgba*)imageData[0])->r),		// base
    sizeof (Rgba),													// xStride
    sizeof (Rgba) * width));								// yStride

  frameBuffer.insert ("G",									// name
    Slice (HALF,														// type
    (char *) &(((Rgba*)imageData[0])->g),		// base
    sizeof (Rgba),													// xStride
    sizeof (Rgba) * width));								// yStride

  frameBuffer.insert ("B",									// name
    Slice (HALF,														// type
    (char *) &(((Rgba*)imageData[0])->b),		// base
    sizeof (Rgba),											    // xStride
    sizeof (Rgba) * width));								// yStride

  exrFile.setFrameBuffer (frameBuffer);
  exrFile.writePixels (height);

  return true;
}
开发者ID:toaarnio,项目名称:tga2exr,代码行数:48,代码来源:tga2exr.cpp

示例10: writeGZ2

void
writeGZ2 (const char fileName[],
	  const half *gPixels,
	  const float *zPixels,
	  int width,
	  int height,
	  const Box2i &dataWindow)
{
    //
    // Write an image with only a G (green) and a Z (depth) channel,
    // using class OutputFile.  Don't store the whole image in the
    // file, but crop it according to the given data window.
    //
    //	- create a file header
    //	- set the header's data window
    //	- add G and Z channels to the header
    //	- open the file, and store the header in the file
    //	- describe the memory layout of the G anx Z pixels
    //	- store the pixels in the file
    //

    Header header (width, height);
    header.dataWindow() = dataWindow;
    header.channels().insert ("G", Channel (IMF::HALF));
    header.channels().insert ("Z", Channel (IMF::FLOAT));

    OutputFile file (fileName, header);

    FrameBuffer frameBuffer;

    frameBuffer.insert ("G",					// name
			Slice (IMF::HALF,			// type
			       (char *) gPixels,		// base
			       sizeof (*gPixels) * 1,		// xStride
			       sizeof (*gPixels) * width));	// yStride

    frameBuffer.insert ("Z",					// name
			Slice (IMF::FLOAT,			// type
			       (char *) zPixels,		// base
			       sizeof (*zPixels) * 1,		// xStride
			       sizeof (*zPixels) * width));	// yStride

    file.setFrameBuffer (frameBuffer);
    file.writePixels (dataWindow.max.y - dataWindow.min.y + 1);
}
开发者ID:Aaaaaaare,项目名称:openexr,代码行数:45,代码来源:generalInterfaceExamples.cpp

示例11: header

void ZFnEXR::saveCameraNZ(float* data, M44f mat, float fov, const char* filename, int width, int height)
{
	Header header (width, height); 
	header.insert ("fov", DoubleAttribute (fov)); 
	header.insert ("cameraTransform", M44fAttribute (mat));
	header.channels().insert ("R", Channel (FLOAT));
	
	OutputFile file (filename, header); 
	FrameBuffer frameBuffer;

	frameBuffer.insert ("R", 
						Slice (FLOAT, 
							   (char *) data, 
							   sizeof (*data) * 1, 
							   sizeof (*data) * width)); 
	file.setFrameBuffer (frameBuffer);              
	file.writePixels (height);
}
开发者ID:saggita,项目名称:makoto,代码行数:18,代码来源:zFnEXR.cpp

示例12: makePreview

void
makePreview (const char inFileName[],
	     const char outFileName[],
	     int previewWidth,
	     float exposure,
	     bool verbose)
{
    if (verbose)
	cout << "generating preview image" << endl;

    Array2D <PreviewRgba> previewPixels;
    int previewHeight;

    generatePreview (inFileName,
		     exposure,
		     previewWidth,
		     previewHeight,
		     previewPixels);

    InputFile in (inFileName);
    Header header = in.header();

    header.setPreviewImage
	(PreviewImage (previewWidth, previewHeight, &previewPixels[0][0]));

    if (verbose)
	cout << "copying " << inFileName << " to " << outFileName << endl;

    if (header.hasTileDescription())
    {
	TiledOutputFile out (outFileName, header);
	out.copyPixels (in);
    }
    else
    {
	OutputFile out (outFileName, header);
	out.copyPixels (in);
    }

    if (verbose)
	cout << "done." << endl;
}
开发者ID:Len3d,项目名称:appleseed,代码行数:42,代码来源:makePreview.cpp

示例13: writeGZ1

void
writeGZ1 (const char fileName[],
	  const half *gPixels,
	  const float *zPixels,
	  int width,
	  int height)
{
    //
    // Write an image with only a G (green) and a Z (depth) channel,
    // using class OutputFile.
    //
    //	- create a file header
    //	- add G and Z channels to the header
    //	- open the file, and store the header in the file
    //	- describe the memory layout of the G anx Z pixels
    //	- store the pixels in the file
    //

    Header header (width, height);
    header.channels().insert ("G", Channel (IMF::HALF));
    header.channels().insert ("Z", Channel (IMF::FLOAT));

    OutputFile file (fileName, header);

    FrameBuffer frameBuffer;

    frameBuffer.insert ("G",					// name
		        Slice (IMF::HALF,			// type
			       (char *) gPixels,		// base
			       sizeof (*gPixels) * 1,		// xStride
			       sizeof (*gPixels) * width));	// yStride

    frameBuffer.insert ("Z",					// name
			Slice (IMF::FLOAT,			// type
			       (char *) zPixels,		// base
			       sizeof (*zPixels) * 1,		// xStride
			       sizeof (*zPixels) * width));	// yStride

    file.setFrameBuffer (frameBuffer);
    file.writePixels (height);
}
开发者ID:Aaaaaaare,项目名称:openexr,代码行数:41,代码来源:generalInterfaceExamples.cpp

示例14: SaveCharstringCode

EStatusCode OpenTypeTest::SaveCharstringCode(unsigned short inFontIndex,unsigned short inGlyphIndex,CFFFileInput* inCFFFileInput)
{
	OutputFile glyphFile;

	EStatusCode status = glyphFile.OpenFile(string("C:\\PDFLibTests\\glyphCFF")  + Long(inFontIndex).ToString() + "_" + inCFFFileInput->GetGlyphName(0,inGlyphIndex) + ".txt");

	do
	{
		if(status != PDFHummus::eSuccess)
			break;
		
		CharStringType2Tracer tracer;

		status = tracer.TraceGlyphProgram(inFontIndex,inGlyphIndex,inCFFFileInput,glyphFile.GetOutputStream());

	}while(false);

	glyphFile.CloseFile();

	return status;
}
开发者ID:GunioRobot,项目名称:PDF-Writer,代码行数:21,代码来源:OpenTypeTest.cpp

示例15: Run

EStatusCode PFBStreamTest::Run(const TestConfiguration& inTestConfiguration)
{
	EStatusCode status;
	InputFile pfbFile;
	OutputFile decodedPFBFile;
	InputPFBDecodeStream decodeStream;

	do
	{
		pfbFile.OpenFile(RelativeURLToLocalPath(inTestConfiguration.mSampleFileBase,"TestMaterials/fonts/HLB_____.PFB"));

		decodedPFBFile.OpenFile(RelativeURLToLocalPath(inTestConfiguration.mSampleFileBase,"decodedPFBFile.txt"));


		status = decodeStream.Assign(pfbFile.GetInputStream());
		
		if(status != PDFHummus::eSuccess)
		{
			cout<<"Failed to assign pfb input stream";
			break;
		}

		OutputStreamTraits traits(decodedPFBFile.GetOutputStream());

		status = traits.CopyToOutputStream(&decodeStream);

		if(status != PDFHummus::eSuccess)
		{
			cout<<"Failed to decode pfb stream";
			break;
		}
	}while(false);

	decodeStream.Assign(NULL);
	pfbFile.CloseFile();
	decodedPFBFile.CloseFile();

	return status;
}
开发者ID:CornerZhang,项目名称:PDF-Writer,代码行数:39,代码来源:PFBStreamTest.cpp


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