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


C++ BMP::WriteToFile方法代码示例

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


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

示例1: writeFile

//store output data to disk
void writeFile(BMP img, int id, int iter){
	string name;
	stringstream sstm;
	if(id==1){
		for (short i =0; i<HEIGHT; i++){
			for (short j = 0; j<WIDTH; j++){
				img(i,j)->Red = (label[i][j] +3)*42; //normalize to [0, 255]
				img(i,j)->Green = (label[i][j] +3)*42;
				img(i,j)->Blue = (label[i][j] +3)*42;
			}
		}
		
		sstm << iter << "label" <<".bmp";
		name = sstm.str();
		img.WriteToFile(name.c_str());
		printf("\nlabel image stored");
	}
	else{ //zeroLevelSet
		for (short i =0; i<HEIGHT; i++){
			for (short j = 0; j<WIDTH; j++){
				img(i,j)->Red = zeroLevelSet[i][j]; 
				img(i,j)->Green = zeroLevelSet[i][j]; 
				img(i,j)->Blue = zeroLevelSet[i][j]; 
			}
		}
		sstm << iter << "zero" <<".bmp";
		name = sstm.str();
		img.WriteToFile(name.c_str());
		printf("\nzero image stored\n");
	}
}
开发者ID:N4TT,项目名称:LevelSet,代码行数:32,代码来源:main.cpp

示例2: writeFile

void writeFile(BMP img, int id){
	if(id == 1){ //label
		for (int i =0; i<HEIGHT; i++){
			for (int j = 0; j<WIDTH; j++){
				img(i,j)->Red = (label[i][j] +3)*42; //normalize to [0, 255]
				img(i,j)->Green = (label[i][j] +3)*42;
				img(i,j)->Blue = (label[i][j] +3)*42;
			}
		}
		img.WriteToFile("output label.bmp");
		printf("\nlabel image stored");
	}
	else{ //zeroLevelSet
		for (int i =0; i<HEIGHT; i++){
			for (int j = 0; j<WIDTH; j++){
				//printf(" (%i,%i) ", i, j);
				img(i,j)->Red = zeroLevelSet[i][j]; 
				img(i,j)->Green = zeroLevelSet[i][j]; 
				img(i,j)->Blue = zeroLevelSet[i][j]; 
			}
		}
		img.WriteToFile("output zero.bmp");
		printf("\nzero image stored\n");
	}
}
开发者ID:N4TT,项目名称:LevelSet,代码行数:25,代码来源:IO.cpp

示例3: pacmanTests

void pacmanTests() {
	cout << "Testing PacMan" << endl;

	// PAC MAN BFS
	BMP img;
	img.ReadFromFile("pacMan.bmp");
	rainbowColorPicker BFSfiller(1.0/1000.0);
	animation pacManBFS = BFSfill(img, img.TellWidth()/2, img.TellHeight()/2,
	                               BFSfiller, 8000, INT_MAX);
	img.WriteToFile("pacManBFS.bmp");
	cout << "\tWrote pacManBFS.bmp" << endl;
	//blueManBFS.write("pacManBFS.gif");

	// PAC MAN DFS
	img.ReadFromFile("pacMan.bmp");
	rainbowColorPicker DFSfiller(1.0/1000.0);
	animation pacManDFS = DFSfill(img, img.TellWidth()/2, img.TellHeight()/2,
	                               DFSfiller, 8000, INT_MAX);
	img.WriteToFile("pacManDFS.bmp");
	cout << "\tWrote pacManDFS.bmp" << endl;


	// Make ANTI image
	BMP antiImg;
	antiImg.ReadFromFile("pacMan.bmp");
	RGBApixel black;
	black.Red = black.Green = black.Blue = 0;
	RGBApixel grey;
	grey.Red = grey.Green = grey.Blue = 1;
	BFSfillSolid(antiImg, 10, 10, grey, 8000, INT_MAX);
	BFSfillSolid(antiImg, antiImg.TellWidth()/2, antiImg.TellHeight()/2, black, 8000, INT_MAX);

	// ANTI PAC MAN BFS
	img = antiImg;
	rainbowColorPicker aBFSfiller(1.0/1000.0);
	animation aManBFS = BFSfill(img, 20, 20, aBFSfiller, 0, 2000);
	//img.WriteToFile("antiPacManBFS.bmp");
	aManBFS.write("antiPacManBFS.gif");
	cout << "\tWrote antiPacManBFS.gif" << endl;

	// ANTI PAC MAN DFS
	img = antiImg;
	rainbowColorPicker aDFSfiller(1.0/1000.0);
	animation aManDFS = DFSfill(img, 20, 20, aDFSfiller, 0, 2000);
	//img.WriteToFile("antiPacManDFS.bmp");
	aManDFS.write("antiPacManDFS.gif");
	cout << "\tWrote antiPacManDFS.gif" << endl;
}
开发者ID:leloulight,项目名称:cs225,代码行数:48,代码来源:testFills.cpp

示例4: EasyBMP_Screenshot

bool EasyBMP_Screenshot( const char* FileName )
{
    BMP Output;

    GLsizei viewport[4];
    glGetIntegerv( GL_VIEWPORT , viewport );

    int width = viewport[2] - viewport[0];
    int height = viewport[3] - viewport[1];

    Output.SetSize(width,height);

    GLint swapbytes, lsbfirst, rowlength, skiprows, skippixels, alignment;

    /* Save current pixel store state. */
    glGetIntegerv(GL_UNPACK_SWAP_BYTES, &swapbytes);
    glGetIntegerv(GL_UNPACK_LSB_FIRST, &lsbfirst);
    glGetIntegerv(GL_UNPACK_ROW_LENGTH, &rowlength);
    glGetIntegerv(GL_UNPACK_SKIP_ROWS, &skiprows);
    glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &skippixels);
    glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment);

    /* Set desired pixel store state. */

    glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE);
    glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE);
    glPixelStorei(GL_UNPACK_ROW_LENGTH, 0);
    glPixelStorei(GL_UNPACK_SKIP_ROWS, 0);
    glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0);
    glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

    RGBApixel* pixels;
    pixels = new RGBApixel [ Output.TellWidth() * Output.TellHeight() ];
    glReadPixels( viewport[0],viewport[1], width,height, GL_RGBA, GL_UNSIGNED_BYTE, pixels);

    int n=0;
    for( int j=Output.TellHeight()-1 ; j >= 0 ; j-- )
    {
        for( int i=0; i < Output.TellWidth() ; i++ )
        {
            Output(i,j)->Red = (pixels[n]).Blue;
            Output(i,j)->Green = (pixels[n]).Green;
            Output(i,j)->Blue = (pixels[n]).Red;
            n++;
        }
    }

    /* Restore current pixel store state. */
    glPixelStorei(GL_UNPACK_SWAP_BYTES, swapbytes);
    glPixelStorei(GL_UNPACK_LSB_FIRST, lsbfirst);
    glPixelStorei(GL_UNPACK_ROW_LENGTH, rowlength);
    glPixelStorei(GL_UNPACK_SKIP_ROWS, skiprows);
    glPixelStorei(GL_UNPACK_SKIP_PIXELS, skippixels);
    glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);


    Output.WriteToFile( FileName );

    return true;
}
开发者ID:sytrus-in-github,项目名称:X-Toon-shader,代码行数:60,代码来源:EasyBMP_OpenGL.cpp

示例5: array2bmp

//数组转图像
void array2bmp()
{
    int i,j;
    BMP bmp;
    RGBApixel pix_black={0};//R=0 G=0 B=0为黑色
    RGBApixel pix_white={255,255,255,0};//白色

    bmp.SetSize(3,3);
    bmp.SetBitDepth(1);
    for(i=0;i<3;i++)
    {
        for(j=0;j<3;j++)
        {
            if(array[i][j]==1)
            {
                bmp.SetPixel( i,  j,pix_black);
            }
            else
            {
                bmp.SetPixel( i,  j,pix_white);
            }
        }
    }

    bmp.WriteToFile("examp_array2bmp.bmp");
    printf("array2bmp suc...\n");
}
开发者ID:bbky,项目名称:CodeBase,代码行数:28,代码来源:main.cpp

示例6: raytrace

void Camera::raytrace(Node *node, const std::vector<Light*>& lights) {
  BMP output;
  output.SetSize(width,height);
  output.SetBitDepth(24);
  for(int i = 0; i < width; i++) {
    for(int j = 0; j < height; j++) {
      output(i,j)->Red = 0;
      output(i,j)->Green = 0;
      output(i,j)->Blue = 0;
    }
  }

  float aRatio = (float)width/height;

  glm::vec3 xAxis = glm::cross(fwd, up);
  glm::vec3 yAxis = glm::cross(xAxis, fwd);

  float xFov = std::atan(std::tan(yFov) * aRatio);

  xAxis *= std::tan(xFov/2) * glm::length(fwd) / glm::length(xAxis);
  yAxis *= std::tan(yFov/2) * glm::length(fwd) / glm::length(yAxis);

  for(unsigned int j = 0; j < height; j++) {
    std::cout << "\rline " << j << std::flush;
    #pragma omp parallel for
    for(unsigned int i = 0; i < width; i++) {

      // indirect illumination
      glm::vec3 color(0);
      for(int d = 0; d < density; d++) {
        float x = (float(i) + float(rand())/RAND_MAX) / width;
        float y = (float(j) + float(rand())/RAND_MAX) / height;
        std::cout << "dbg " << fwd << " " << xAxis << " " << yAxis << "\n";
        glm::vec3 dir = glm::normalize(fwd + (2*x-1)*xAxis + (1-2*y)*yAxis);
        Ray ray(pos, dir, rayCount, true);

        glm::vec4 dirCol = rayIter(ray, node, lights);
        glm::vec3 mcCol;
        if(dirCol[3] < 1 && mcIter > 0) {
          for(int w = 0; w < mcIter; w++)
            mcCol += rayIter(ray,node);
          mcCol /= float(mcIter);
        } else {
          dirCol[3] = 1;
        }
        color += (1.f - dirCol[3])*mcCol + dirCol[3]*glm::vec3(dirCol);
      }
      color /= float(density);


      output(i,j)->Red = 255.0*glm::clamp(color[0],0.f,1.f);
      output(i,j)->Green = 255.0*glm::clamp(color[1],0.f,1.f);
      output(i,j)->Blue = 255.0*glm::clamp(color[2],0.f,1.f);
    }
  }
  output.WriteToFile(outFile.c_str());
  exit(0);
}
开发者ID:krupkad,项目名称:Krender,代码行数:58,代码来源:camera.cpp

示例7: encode

void encode(string infile, string outfile, string payload)
{
	BMP input;
	if(!input.ReadFromFile(infile.c_str()))
	{
		cout << "The Bitmap doesn\'t exist!" << endl;
		return;
	}
	int msglength = payload.length() * 2;
	if(msglength > input.TellWidth() * input.TellHeight())
	{
		cout << "That message is too large for that image! (" << msglength << " as opposed to " << input.TellWidth() * input.TellHeight() << "; " << input.TellWidth() << " * " << input.TellHeight() << ")"<<endl;
		return;
	}
	stringstream msglength_ss;
	msglength_ss << setfill('0') << setw(8) << hex << msglength;
	string msglength_str = msglength_ss.str();

	uchar msgLength_split[8];
	for(uint i = 0; i < msglength_str.length(); i++)
	{
		msgLength_split[i] = (uchar)single_char_to_int(msglength_str[i]);
	}

	char* payload_split = new char[payload.length() * 2];
	for(uint i = 0; i < payload.length() * 2 - 1; i+=2)
	{
		payload_split[i] = payload[i / 2] >> 4;
		payload_split[i + 1] = payload[i/ 2] & 0x0F;
	}
	RGBApixel pix;
	for(int x = 0; x < 8; x++)
	{
		pix = input.GetPixel(x, 0);
		pix.Blue &= 0xF0;
		pix.Blue += msgLength_split[x];
		input.SetPixel(x, 0, pix);
	}

	for(int y = 0; y < input.TellHeight(); y++)
	{
		for(int x = 0; x < input.TellWidth(); x++)
		{
			if(y == 0 && x < 8)
				continue;
			pix = input.GetPixel(x, y);
			if(payload.length() * 2 > (uint)input.TellWidth() * y + x - 8)
			{
				pix.Blue &= 0xF0;
				pix.Blue += payload_split[input.TellWidth() * y + x - 8];
			}
			input.SetPixel(x, y, pix);
		}
	}
	fclose(fopen(outfile.c_str(),"w"));
	input.WriteToFile(outfile.c_str());
	delete[] payload_split;
}
开发者ID:techzoneat,项目名称:image-stegano,代码行数:58,代码来源:main.cpp

示例8: writeToBMPFile

bool Image::writeToBMPFile(const std::string & outputFileName)
{
  bool success = true;

  if( m_pixels != NULL )
    {
    // create bitmap image
    BMP outputImage;
    outputImage.SetSize(m_numCols, m_numRows);
    outputImage.SetBitDepth( 24 );

    double maxVal = m_pixels[0];
    double minVal = m_pixels[0];
    // Maximum and minimum values
    for( int i = 1; i < m_numRows * m_numCols; ++i )
      {
      if( m_pixels[i] > maxVal )
        {
        maxVal = m_pixels[i];
        }
      if( m_pixels[i] <= minVal )
        {
        minVal = m_pixels[i];
        }
      }
    for( int r = 0; r < m_numRows; ++r )
      {
      for( int c = 0; c < m_numCols; ++c )
        {
        // get pixel value and clamp between 0 and 255
        double val = 255.0 * (m_pixels[r * m_numCols + c] - minVal) / (maxVal - minVal);

        if( val < 0 )
          {
          val = 0;
          }
        if( val > 255 )
          {
          val = 255;
          }
        // set output color based on mapping
        RGBApixel pixelVal;
        pixelVal.Blue = (int)val; pixelVal.Green = (int)val; pixelVal.Red = (int)val;
        outputImage.SetPixel(c, r, pixelVal);
        }
      }

    // write to file
    success = outputImage.WriteToFile( outputFileName.c_str() );

    }
  else
    {
    success = false;
    }

  return success;
}
开发者ID:zachary-williamson,项目名称:robotics-bosscode,代码行数:58,代码来源:Image.cpp

示例9: outputImage

void outputImage(const char *filename = "out.bmp", const char *rawfilename = "out.raw")
{
	//raw output
	target->ToRawFile(rawfilename);

	//bmp output
	BMP out;
	target->ToBMP(out);
	out.WriteToFile(filename);
}
开发者ID:ReaperUnreal,项目名称:Raytracer,代码行数:10,代码来源:main.cpp

示例10:

static cell AMX_NATIVE_CALL n_SetImageSize( AMX* amx, cell* params ){
	amx_StrParam(amx,params[1],tmp);
	posx = params[2];
	posy = params[3];
	BMP Image;
	Image.ReadFromFile(tmp);
	Image.CreateStandardColorTable();
	Image.SetSize(posx,posy);
	return Image.WriteToFile(tmp);
}
开发者ID:berke123123,项目名称:GPB,代码行数:10,代码来源:pwncurl.cpp

示例11: testTripleRotate

// test -- tripleRotate()
void testTripleRotate()
{
   int width, height;
   List<RGBApixel> pixelList;
   setup("in_02.bmp", pixelList, width, height);
   pixelList.tripleRotate(4);

   BMP imgOut;
   buildImage(imgOut, pixelList, width, height);
   imgOut.WriteToFile("rotated.bmp");
}
开发者ID:leloulight,项目名称:cs225,代码行数:12,代码来源:testparttwo.cpp

示例12: w2f

void w2f(GlobalMap &globalMap, int i, int j, int size=1025)
{
	char fileName[6] = {'0','0','.','b','m','p'};
	fileName[0]=i+48;
	fileName[1]=j+48;
		
	short z;
		
	RGBApixel color;
	BMP image;
	image.SetSize(size,size);
	image.SetBitDepth(16);

	for(int y=0; y<size; y++)
	{
		for(int x=0; x<size; x++)
		{
			z= globalMap.getLocalMap(i,j)->getHeight(x,y);
			if(z<0)
			{
				color.Red=0;
				color.Green=0;
				color.Blue=(z+32768)/129;
				color.Alpha=0;
			}
			if(z>=0 && z<20000)
			{	
				color.Red=0;
				color.Green=z/134+100;
				color.Blue=0;
				color.Alpha=0;
			}
			if(z>=20000 && z<25000)
			{
				color.Red=(z-20000)/500+200;
				color.Green=(z-20000)/500+200;
				color.Blue=(z-20000)/500+200;
				color.Alpha=0;
			}
			if(z>=25000)
			{
				color.Red=255;
				color.Green=255;
				color.Blue=255;
				color.Alpha=0;
			}
			
			image.SetPixel(x,y, color);
		}
	}

	image.WriteToFile(fileName);
}
开发者ID:Psycojoker,项目名称:topomap,代码行数:53,代码来源:main.cpp

示例13: pixelsToBitmap

void BitmapRawConverter::pixelsToBitmap(char *outFilename) {
    BMP out;
    out.SetSize(width, height);
    out.SetBitDepth(24);

    for (int i = 0; i < width; i++) {
        for (int j = 0; j < height; j++) {
            out.SetPixel(i, j, getPixel(i,j));
        }
    }
    out.WriteToFile(outFilename);
}
开发者ID:ljmocic,项目名称:SPPuRV,代码行数:12,代码来源:BitmapRawConverter.cpp

示例14: main

int main()
{ 
   SquareMaze m;
   m.makeMaze(2,2);
   std::cout << "MakeMaze complete" << std::endl;

   BMP* unsolved = m.drawMaze();
   unsolved->WriteToFile("unsolved.bmp");
   delete unsolved;
   std::cout << "drawMaze complete" << std::endl;

 
   m.solveMaze();
   std::cout << "solveMaze complete" << std::endl;

   BMP* solved = m.drawMazeWithSolution();
   solved->WriteToFile("solved.bmp");
   delete solved;
   std::cout << "drawMazeWithSolution complete" << std::endl;

   return 0;
}
开发者ID:leloulight,项目名称:cs225,代码行数:22,代码来源:testsquaremaze.cpp

示例15: main

int main(int argc, char** argv) {

    if (argc != 2) {
        cout << "Incorrect input. Please enter the name of the configuration file." << endl; 
        return -1; 
    } 
    Reader * config = new Reader(argv[1]);
    
    int width = config->getWIDTH();
    int height = config->getHEIGHT();
    int x = config->getX();
    int y = config->getY();
    int z = config->getZ();

    Camera * rayGenerator = new Camera(config->getEYEP(), config->getVDIR(), 
                                                config->getUVEC(), config->getFOVY(), width, height);
    BMP output;
    output.SetSize(width, height);
    output.SetBitDepth(24);

    Raymarch * raymarch = new Raymarch(config->getVB(), rayGenerator, config->getEYEP(), 
                                        config->getMRGB(), config->getBRGB(), 
                                        config->getLCOL(), config->getLPOS(), config->getOFST());
    
    for (int w = 0; w < width; w++) {
		cout << "Rendering: " << (float) w/width << endl;
        for (int h = 0; h < height; h++) {
            /*
            // Ray direction color test
            output(w,h)->Red = abs(rayGenerator->getRayDirection(w,h).x) *255;
            output(w,h)->Green = abs(rayGenerator->getRayDirection(w,h).y) *255;
            output(w,h)->Blue = abs(rayGenerator->getRayDirection(w,h).z) *255;
            */
            glm::vec3 colors = raymarch->getColor(w,h, config->getSTEP(), glm::vec3(x, y, z));
            colors*=255.0;
            if (colors.x > 255) 
                colors.x = 255;
            if (colors.y > 255) 
                colors.y = 255;
            if (colors.z > 255) 
                colors.z = 255;
            output(w,h)->Red =colors.x;
            output(w,h)->Green = colors.y;
            output(w,h)->Blue = colors.z;
        }
    }
    
    output.WriteToFile(config->getFILE());
	cout << "File has been finished rendering." <<endl;
    return 0;
}
开发者ID:justinhlee,项目名称:voxel-renderer,代码行数:51,代码来源:main.cpp


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