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


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

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


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

示例1: main

int main( int argc, char *argv[] )
{
    cout << endl
         << "Using EasyBMP Version " << _EasyBMP_Version_ << endl << endl
         << "Copyright (c) by the EasyBMP Project 2005-6" << endl
         << "WWW: http://easybmp.sourceforge.net" << endl << endl;

    BMP Text;
    Text.ReadFromFile("EasyBMPtext.bmp");

    BMP Background;
    Background.ReadFromFile("EasyBMPbackground.bmp");

    BMP Output;
    Output.SetSize( Background.TellWidth() , Background.TellHeight() );
    Output.SetBitDepth( 24 );

    RangedPixelToPixelCopy( Background, 0, Output.TellWidth() - 1,
                            Output.TellHeight() - 1 , 0,
                            Output, 0, 0 );

    RangedPixelToPixelCopyTransparent( Text, 0, 380,
                                       43, 0,
                                       Output, 110, 5,
                                       *Text(0, 0) );

    RangedPixelToPixelCopyTransparent( Text, 0, Text.TellWidth() - 1,
                                       Text.TellWidth() - 1, 50,
                                       Output, 100, 442,
                                       *Text(0, 49) );

    Output.SetBitDepth( 32 );
    cout << "writing 32bpp ... " << endl;
    Output.WriteToFile( "EasyBMPoutput32bpp.bmp" );

    Output.SetBitDepth( 24 );
    cout << "writing 24bpp ... " << endl;
    Output.WriteToFile( "EasyBMPoutput24bpp.bmp" );

    Output.SetBitDepth( 8 );
    cout << "writing 8bpp ... " << endl;
    Output.WriteToFile( "EasyBMPoutput8bpp.bmp" );

    Output.SetBitDepth( 4 );
    cout << "writing 4bpp ... " << endl;
    Output.WriteToFile( "EasyBMPoutput4bpp.bmp" );

    Output.SetBitDepth( 1 );
    cout << "writing 1bpp ... " << endl;
    Output.WriteToFile( "EasyBMPoutput1bpp.bmp" );

    Output.SetBitDepth( 24 );
    Rescale( Output, 'p' , 50 );
    cout << "writing 24bpp scaled image ..." << endl;
    Output.WriteToFile( "EasyBMPoutput24bpp_rescaled.bmp" );

    return 0;
}
开发者ID:github188,项目名称:BasicFunctionCodeBase,代码行数:58,代码来源:easybmpTest.cpp

示例2: main

int main (){
   
   // initializing variables

   bool sucess;
   BMP in;
   BMP out;
   int width,height,i,j,new_j,new_i;

   // Set Classes to contain image

   sucess=in.ReadFromFile("in.bmp");
   //cout<<sucess<<endl;
   sucess=out.ReadFromFile("in.bmp");
   //cout<<sucess<<endl;

   // Find height and width
   // starting from 0 not 1 so decrement 
  
   width=(in.TellWidth());
   width--;
   height=in.TellHeight();
   height--;
   //cout<<in.TellWidth()<<endl;
   //cout<<in.TellHeight()<<endl;

   // runs horizontally across the image
   for (i=0;i<=width;i++){

      // runs vertically across image
      for (j=0;j<=height;j++){

         // code for finding pixel to change 
         new_i=width-i;
         new_j=height-j;

         // code for changing output image  
         out(new_i,new_j)->Red =in(i,j)->Red;
         out(new_i,new_j)->Green =in(i,j)->Green;
         out(new_i,new_j)->Blue =in(i,j)->Blue;
        
      }	
   }
   //cout<<"Exiting For loops"<<endl;
   
   // write output image to disk
   out.WriteToFile("out.bmp");
   //cout<<"Finished writing out.bmp"<<endl;
   return 0;
}
开发者ID:fightingillini5,项目名称:cs225-1,代码行数:50,代码来源:main.cpp

示例3: testGridFills

void testGridFills() {
	BMP img;
	img.ReadFromFile(GRIDTESTIMAGE);
	RGBApixel px;
	px.Red = px.Blue = 70;
	px.Green = 25;

	animation anim = BFSfillGrid(img, GRIDX, GRIDY, px, GRIDGRIDSPACING, GRIDTOLERANCE, GRIDFRAMEFREQ);
	anim.write("bfsGridTest.gif");
	cout << "\tWrote bfsGridTest.gif" << endl;
	img.ReadFromFile(GRIDTESTIMAGE);
	anim = DFSfillGrid(img, GRIDX, GRIDY, px, GRIDGRIDSPACING, GRIDTOLERANCE, GRIDFRAMEFREQ);
	anim.write("dfsGridTest.gif");
	cout << "\tWrote dfsGridTest.gif" << endl;
}
开发者ID:leloulight,项目名称:cs225,代码行数:15,代码来源:testFills.cpp

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

示例5: if

// filename is a BMP file
CImage::CImage(const char * filename, int colors)
{
    BMP bmp;
    bmp.ReadFromFile(filename);
    init(bmp.TellWidth(), bmp.TellHeight(), colors);

    // convert pixels to float values
    for (int col = 0; col < m_width; col++)
    {
        for (int row = 0; row < m_height; row++)
        {
            RGBApixel* pixel = bmp(col, row);

            // m_color == 1 means grayscale... so all components should be equal
            // (i.e. Red = Green = Blue)
            if (m_color == 1)
                setValue(row, col, 0, (float) pixel->Red);
            else if (m_color == 3)
            {
                setValue(row, col, 0, (float) pixel->Red);
                setValue(row, col, 1, (float) pixel->Green);
                setValue(row, col, 2, (float) pixel->Blue);
            }
        }
    }

}
开发者ID:ibrahim-amer,项目名称:StereoVision,代码行数:28,代码来源:cimage.cpp

示例6: loadImage

unsigned int loadImage(const char * fname)
{
	if ( ! fname )
	{
		return 0;
	}
	BMP bmp;
	if ( ! bmp.ReadFromFile(fname) )
	{
		printf( "not loaded : %s\n",fname );
		return 0;
	}

	int w = bmp.TellWidth();
	int h = bmp.TellHeight();
	int d = bmp.TellBitDepth() / 8;
    RGBApixel* pix = bmp(0,0);
    char bytes[0x7ffff], *b=bytes;
    for ( int j=0; j<h; j++ )
    {
        for ( int i=0; i<w; i++ )
        {
			RGBApixel pix = bmp.GetPixel(i, j);
            *b++ = pix.Red;
            *b++ = pix.Green;
            *b++ = pix.Blue;
			if ( d == 4 )
				*b++ = pix.Alpha;            
        }        
    }
    size_t i = RGL::texCreate( w, h, d, bytes, true );;
    printf( "created : %d [%d %d %d] %s\n", i, w,h,d,fname );
    return i;
}
开发者ID:berak,项目名称:vst2.0,代码行数:34,代码来源:main.cpp

示例7: testSolidFills

void testSolidFills() {
	BMP img;
	img.ReadFromFile(SOLIDTESTIMAGE);
	RGBApixel px;
	px.Red = 70;
	px.Green = 50;
	px.Blue = 13;

	animation anim = DFSfillSolid(img, SOLIDX, SOLIDY, px, SOLIDTOLERANCE, SOLIDFRAMEFREQ);
	anim.write("dfsSolidTest.gif");
	cout << "\tWrote dfsSolidTest.gif" << endl;
	img.ReadFromFile(SOLIDTESTIMAGE);
	anim = BFSfillSolid(img, SOLIDX, SOLIDY, px, SOLIDTOLERANCE, SOLIDFRAMEFREQ);
	anim.write("bfsSolidTest.gif");
	cout << "\tWrote bfsSolidTest.gif" << endl;
}
开发者ID:leloulight,项目名称:cs225,代码行数:16,代码来源:testFills.cpp

示例8: readFromBMPFile

bool Image::readFromBMPFile(const std::string & inputFileName)
{
  bool success = true;

  // use BMP object to read image
  BMP inputImage;

  success = inputImage.ReadFromFile(inputFileName.c_str() );
  if( success )
    {
    // allocate memory for image (deleting old, if exists)
    m_numRows = inputImage.TellHeight();
    m_numCols = inputImage.TellWidth();
    if( m_pixels != NULL )    // deallocate old memory
      {
      delete [] m_pixels;
      }
    m_pixels = new double[m_numRows * m_numCols];
    // copy pixels
    for( int r = 0; r < m_numRows; ++r )
      {
      for( int c = 0; c < m_numCols; ++c )
        {
        RGBApixel pixelVal = inputImage.GetPixel(c, r);
        double    val = (double) pixelVal.Blue + (double) pixelVal.Green + (double) pixelVal.Red;
        val = (val / 3.0 + 0.5);
        m_pixels[r * m_numCols + c] = val;
        }
      }
    }

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

示例9: main

int main()
{
	BMP srcBMP;
	srcBMP.ReadFromFile("../../../../input/lena.bmp");
	BMP dstBMP(srcBMP);

	int width =srcBMP.TellWidth();
	int height=srcBMP.TellHeight();
	int size  =width*height;

	unsigned char* srcData= new unsigned char[width*height];
	unsigned char* dstData= new unsigned char[width*height];

	BMP2graydata(srcBMP, srcData);
	//sobel( srcData, dstData, width, height);
	//------- run sobel on nmc --------------
	// Access and loading program to nm-board
	C_PC_Connector_mc5103 Connector(PROGRAM);
	if (!Connector.isConnected()){
		printf("Connection to mc5103 error!");
		return -1;
	}

	int handshake= Connector.Sync(0xC0DE0086);
	if (handshake!=0xC0DE6406){
		printf("Handshake with mc5103 error!");
		return -1;
	}
	
	
	int ok;
	ok=Connector.Sync(width);		// Send width to nmc
	ok=Connector.Sync(height);		// Send height to nmc
	ok=Connector.Sync(0);			// Get	status of memory allocation from nm
	if (ok!=0x600DB00F){
		printf("Memory allocation error!");
		return -1;
	}
	unsigned srcAddr=Connector.Sync(0);
	unsigned dstAddr=Connector.Sync(0);
	
	Connector.WriteMemBlock((unsigned*)srcData, srcAddr, size/4);	// Send data to NMC
	Connector.Sync(0);												// Barrier sync before call of Sobel filter on NMC
	//... wait while sobel is runing on board

	unsigned t=Connector.Sync(0);									// Barrier sync. Wait until Sobel filter is finished
	Connector.ReadMemBlock ((unsigned*)dstData, dstAddr, size/4);	// Recieve result data from NMC
			
			
	
	//----------------------
	graydata2BMP(dstData, dstBMP);

	dstBMP.WriteToFile("dst.bmp");
	
	delete srcData;
	delete dstData;
    return 0;
}
开发者ID:RC-MODULE,项目名称:sobel-steps,代码行数:59,代码来源:main.cpp

示例10: Image

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

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

示例12: testGradientFills

void testGradientFills() {
	BMP img;
	img.ReadFromFile(GRADIENTTESTIMAGE);
	RGBApixel px;
	px.Red = px.Blue = 0;
	px.Green = 25;
	RGBApixel px2;
	px2.Red = px2.Blue = 200;
	px2.Green = 25;

	animation anim = BFSfillGradient(img, GRADIENTX, GRADIENTY, px, px2, GRADIENTRADIUS, GRADIENTTOLERANCE, GRADIENTFRAMEFREQ);
	anim.write("bfsGradientTest.gif");
	cout << "\tWrote bfsGradientTest.gif" << endl;
	img.ReadFromFile(GRADIENTTESTIMAGE);
	anim = DFSfillGradient(img, GRADIENTX, GRADIENTY, px, px2, GRADIENTRADIUS, GRADIENTTOLERANCE, GRADIENTFRAMEFREQ);
	anim.write("dfsGradientTest.gif");
	cout << "\tWrote dfsGradientTest.gif" << endl;
}
开发者ID:leloulight,项目名称:cs225,代码行数:18,代码来源:testFills.cpp

示例13: main

int main(int argc, char * argv[])
{
    if (argc < 3)
    {
        std::cerr << "Usage: " << argv[0] << " <font name> <font image>...\n";
        return 1;
    }

    // Average symbol information
    std::map<char, OCR::Font::Symbol> average;

    // Image
    BMP img;

    // Load a non-existent font
    OCR::Font bogus("BOGUS");

    // Open file for output
    std::string outFileName = argv[1];
    outFileName = "font/" + outFileName + ".font";
    std::ofstream outFile(outFileName.c_str());

    // Load each line and read its statistics
    for (int fileNum = 2; fileNum < argc; ++fileNum)
    {
        // Create line
        img.ReadFromFile(argv[fileNum]);
        OCR::Line line(img, bogus);

        // Create vector for symbol info
        std::vector<OCR::Font::Symbol> symbols;
        symbols.reserve(ALPHABET.size());

        // Do the reading
        line.Read(&symbols);

        // Loop through and add to the "average"
        std::vector<OCR::Font::Symbol>::iterator itr = symbols.begin();
        for (unsigned charIndex = 0; itr != symbols.end() && charIndex
                < ALPHABET .size(); ++itr, ++charIndex)
        {
            average[ALPHABET[charIndex]] += *itr;
        }
    }

    for (std::map<char, OCR::Font::Symbol>::iterator itr = average.begin(); itr
            != average.end(); ++itr)
    {
        // Divide all statistics by number of lines read
        itr->second /= (argc - 2);
        // Print the character and its statistics to the file
        outFile << itr->first << ' ' << itr->second << std::endl;
    }

    outFile.close();
    return 0;
}
开发者ID:ArumugamG,项目名称:OCR,代码行数:57,代码来源:learn.cpp

示例14:

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

示例15: LoadImages

/**Load images by list of files 'file_list' and store them in 'data_set'

*/
void LoadImages(const TFileList& file_list, TDataSet* data_set) {
    for (size_t img_idx = 0; img_idx < file_list.size(); ++img_idx) {
            // Create image
        BMP* image = new BMP();
            // Read image from file
        image->ReadFromFile(file_list[img_idx].first.c_str());
            // Add image and it's label to dataset
        data_set->push_back(make_pair(image, file_list[img_idx].second));
    }
}
开发者ID:alisakhatipova,项目名称:ObjectClassification-SSEacceleration,代码行数:13,代码来源:task2.cpp


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