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


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

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


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

示例1: tile

void tile(BMP& Input, BMP& Output) {
    if (Input.TellHeight() == 1) {
        Output.SetPixel(Output.TellWidth() - 1, 0, Input.GetPixel(0, 0));
    }
    else {
        BMP* ScaledInput = new BMP(Input);
        Rescale(*ScaledInput, 'p', 50);

        // SW quadrant
        RangedPixelToPixelCopy(*ScaledInput, 0, ScaledInput -> TellWidth(), 0, ScaledInput -> TellHeight(), 
                Output, Output.TellWidth() - 2 * ScaledInput -> TellWidth(), ScaledInput -> TellHeight());

        // NE quadrant
        tile(*ScaledInput, Output);

        // NW quadrant
        RangedPixelToPixelCopy(Output, Output.TellWidth() - ScaledInput -> TellWidth(), Output.TellWidth() - ScaledInput -> TellWidth() / 2 - 1,
                0, ScaledInput -> TellHeight() - 1, Output, Output.TellWidth() - 2 * ScaledInput -> TellWidth(), 0);

        RangedPixelToPixelCopy(Output, Output.TellWidth() - ScaledInput -> TellWidth(), Output.TellWidth() - ScaledInput -> TellWidth() / 2 - 1,
                0, ScaledInput -> TellHeight() - 1, Output, Output.TellWidth() - 3 * ScaledInput -> TellWidth() / 2, 0);

        // SE quadrant
        RangedPixelToPixelCopy(Output, Output.TellWidth() - ScaledInput -> TellWidth(), Output.TellWidth() - 1, ScaledInput -> TellHeight() / 2,
                ScaledInput -> TellHeight()  - 1, Output, Output.TellWidth() - ScaledInput -> TellWidth(), ScaledInput -> TellHeight());

        RangedPixelToPixelCopy(Output, Output.TellWidth() - ScaledInput -> TellWidth(), Output.TellWidth() - 1, ScaledInput -> TellHeight() / 2,
                ScaledInput -> TellHeight() - 1, Output, Output.TellWidth() - ScaledInput -> TellWidth(), 3 * ScaledInput -> TellHeight() / 2);
    }

}
开发者ID:zgthompson,项目名称:fa13,代码行数:31,代码来源:lab6.cpp

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

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

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

示例5: HBITMAPtoBMP

bool HBITMAPtoBMP(HDC hDC,HBITMAP hBitmap,BMP& OutputImage)
{
 using namespace std;
 bool output = false;
    
 BITMAPINFO BitInfo;
 ZeroMemory(&BitInfo, sizeof(BITMAPINFO));
 BitInfo.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);
 
 // get all manner of information from the incoming bitmap

 if(!::GetDIBits(hDC, hBitmap, 0, 0, NULL, &BitInfo, DIB_RGB_COLORS))
 { return false; }
 
 // Set the size and bit depth of the BMP object

 OutputImage.SetSize( BitInfo.bmiHeader.biWidth ,BitInfo.bmiHeader.biHeight );
 OutputImage.SetBitDepth(32);

 // reconfigure BitInfo.bmiHeader such that the resulting bitmap will be 
 // 32 bits per pixel. This is _MUCH_ simpler 
 
 BitInfo.bmiHeader.biBitCount = 32;
 BitInfo.bmiHeader.biCompression = 0;
 BitInfo.bmiHeader.biSizeImage = OutputImage.TellHeight()*OutputImage.TellWidth()*4;
 
 // I don't understand the +5 part here. -- Paul 

// BYTE *pData = new BYTE[BitInfo.bmiHeader.biSizeImage + 5];
// BYTE *pData = new BYTE[Output.TellHeight()*Output.TellWidth()*4+5];
 BYTE *pData = new BYTE [BitInfo.bmiHeader.biSizeImage];
 
 // now get the actual data
    
 if(!::GetDIBits(hDC, hBitmap, 0, BitInfo.bmiHeader.biHeight, pData, &BitInfo, DIB_RGB_COLORS))
 { return false; }
 
 // transfer that data into the BMP object
 
 int i,j;
 int k=0;
 for( j=OutputImage.TellHeight()-1 ; j >= 0 ; j-- )
 {
  for( i=0; i < OutputImage.TellWidth() ; i++ )
  {
   OutputImage(i,j)->Blue = *(pData+k); k++;
   OutputImage(i,j)->Green = *(pData+k); k++;
   OutputImage(i,j)->Red = *(pData+k); k++;
   OutputImage(i,j)->Alpha = *(pData+k); k++;
  }
 }
 
 delete (pData);
 
 return true;
}
开发者ID:BackupGGCode,项目名称:libbarpp,代码行数:56,代码来源:EasyBMP_win32.cpp

示例6: PadBMP

void PadBMP( BMP& Input , int NewWidth , int NewHeight )
{
// if the NewWidth and NewHight are unchanged, exit

    if( NewWidth  == Input.TellWidth() &&
            NewHeight == Input.TellHeight() )
    {
        return;
    }

// find max range for the copy, so that cropping occurs
// if necessary

    int MaxWidth = Input.TellWidth();
    if( MaxWidth > NewWidth )
    {
        MaxWidth = NewWidth;
    }

    int MaxHeight = Input.TellHeight();
    if( MaxHeight > NewHeight )
    {
        MaxHeight = NewHeight;
    }

// create a temporary image to hold the original pixels

    BMP Temp;
    Temp.SetSize(NewWidth,NewHeight);
    Temp.SetBitDepth( Input.TellBitDepth() );
    int i,j;
    int Difference = Temp.TellHeight() - MaxHeight;
    for( i=0 ; i < MaxWidth ; i++ )
    {
        for( j=0 ; j < MaxHeight ; j++ )
        {
            *Temp(i,j+Difference) = *Input(i,j);
        }
    }

// resize the original image, and recopy the pixels

    Input.SetSize(NewWidth,NewHeight);
    for( i=0 ; i < Input.TellWidth() ; i++ )
    {
        for( j=0 ; j < Input.TellHeight() ; j++ )
        {
            *Input(i,j) = *Temp(i,j);
        }
    }

    Temp.SetSize(1,1);
    Temp.SetBitDepth(24);

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

示例7: CopyBMP

void CopyBMP( BMP& Input , BMP& Output )
{
    Output.SetSize( Input.TellWidth() , Input.TellHeight() );

    for( int j=0 ; j < Input.TellHeight() ; j++ )
    {
        for( int i=0 ; i < Input.TellWidth() ; i++ )
        {
            *Output(i,j) = *Input(i,j);
        }
    }
    return;
}
开发者ID:sytrus-in-github,项目名称:X-Toon-shader,代码行数:13,代码来源:EasyBMP_OpenGL.cpp

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

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

示例10: calculateTextureFromMaterial

Color Sphere::calculateTextureFromMaterial(Point intercept, bool diagnosticEnabled) {
	BMP* texture;
	texture = &this->texture;
	int height = texture->TellHeight();
	int width  = texture->TellWidth();

	Vector vectorToIntercept = intercept - origin;
	vectorToIntercept.normalize();
	double u = 0.5 + atan2(vectorToIntercept.z,vectorToIntercept.x) / 2 / 3.1415;
	double v = 0.5 - asin(vectorToIntercept.y) / 3.1415;

	int pixelX = abs((int)(u * width));
	int pixelY = abs((int)(v * height));
	pixelX %= width;
	pixelY %= height;
	Color matColor;

	if(diagnosticEnabled) {
		matColor = Color(v,0,sin(u * 3.1415));
	}
	else {
		matColor.r = texture->GetPixel(pixelX,pixelY).Red/255.f;
		matColor.g = texture->GetPixel(pixelX,pixelY).Green/255.f;
		matColor.b = texture->GetPixel(pixelX,pixelY).Blue/255.f;
	}

	return matColor;
}
开发者ID:khutchins,项目名称:Naive-Raytracer,代码行数:28,代码来源:ObjSphere.cpp

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

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

示例13: CubicFilter

inline float CubicFilter(int x, int y, const int Radius)
{
	const int DatSize = POW2((Radius << 1) + 1);
	float *Dat = new float[DatSize];
	Cint2 Offset = {x-Radius, y-Radius};
	float Accum = 0.0f;
	int Denom = 0;

	int w = Bmp.TellWidth();
	int h = Bmp.TellHeight();

	for(int Cpt = 0; Cpt < DatSize; Cpt++){
		
		if(Offset.x >= 0 && Offset.x < w && 
		   Offset.y >= 0 && Offset.y < h){

			Accum += RGBMIXER(Offset.x, Offset.y);
			Denom++;
		}

		Offset.x++;
		if(Offset.x - x > Radius){
			Offset.x = x-Radius;
			Offset.y++;
		}

	}

	SAFE_DELETE_ARRAY(Dat);

	return Accum / (float)Denom;
}
开发者ID:SteveBeaupre,项目名称:Vortez3DEngine,代码行数:32,代码来源:HeightMap.cpp

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

示例15: decode

string decode(string infile)
{
	BMP input;
	if(!input.ReadFromFile(infile.c_str()))
	{
		cout << "The input file didn't exist!" << endl;
		return "";
	}
	stringstream ret;
	int count = 0;
	char currentChar;
	RGBApixel pix;
	int msgLength = 0;
	stringstream msglength_ss;
	for(int x = 0; x < 8; x++)
	{
		pix = input.GetPixel(x, 0);
		msglength_ss << hex << (ushort)(pix.Blue & 0x0F);
	}
	msgLength = strtol(msglength_ss.str().c_str(), NULL, 16);
	for(int y = 0; y < input.TellHeight(); y++)
	{
		for(int x = 0; x < input.TellWidth(); x++)
		{
			if(input.TellWidth() * y + x - 8 > msgLength) goto end;
			if(y == 0 && x < 8)
				continue;
			pix = input.GetPixel(x, y);
			if(count % 2 == 0)
			{
				// Begin new Char
				currentChar = pix.Blue & 0x0F;
			}
			else
			{
				// Add to current char
				currentChar <<= 4;
				currentChar += pix.Blue & 0x0F;
				ret << currentChar;
			}
			count++;
		}
	}
	end:
		return ret.str();
}
开发者ID:techzoneat,项目名称:image-stegano,代码行数:46,代码来源:main.cpp


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