All pastes #2105914 Raw Edit

Anonymous

public text v1 · immutable
#2105914 ·published 2012-01-25 04:54 UTC
rendered paste body
	short int magicNumber = 0x4D42;
    short int reserved0 = 0;//0x4D41;
    short int reserved1 = 0;//0x5454;
    unsigned int dataOffset = 54;
    unsigned int infoHeaderSize = 40;
    short int colorPlanes = 1;
    short int bitsPerPixel = 32;
    unsigned int compression = 0;
    unsigned int dataSize = width * height * bitsPerPixel / 8;
    unsigned int horizontalResolution = 2835;
    unsigned int verticalResolution = 2835;
    unsigned int paletteColorCount = 0;
    unsigned int importantPaletteColorCount = 0;
    unsigned int fileSize = 54 + dataSize;
	char intbuffer[33];
	char shortbuffer[17];

	ofstream file (path+=".txt");
	if(file.is_open())
	{
		
		
		file << itoa(magicNumber, shortbuffer, 10);
		file << itoa(fileSize, intbuffer, 10);
		file << itoa(reserved0, shortbuffer, 10);
		file << itoa(reserved1, shortbuffer, 10);
		file << itoa(dataOffset, intbuffer, 10);
		file << itoa(infoHeaderSize, intbuffer, 10);
		file << itoa(width, intbuffer, 10);
		file << itoa(height, intbuffer, 10);
		file << itoa(colorPlanes, shortbuffer, 10);
		file << itoa(bitsPerPixel, shortbuffer, 10);
		file << itoa(compression, intbuffer, 10);
		file << itoa(dataSize, intbuffer, 10);
		file << itoa(horizontalResolution, intbuffer, 10);
		file << itoa(verticalResolution, intbuffer, 10);
		file << itoa(paletteColorCount, intbuffer, 10);
		file << itoa(importantPaletteColorCount, intbuffer, 10);

			//Write BMP body (XXRRGGBB)
		for (int y = height - 1; y >= 0; y--)
		{
			for (int x = 0; x < width; x++)
			{
				ColorARGB pixel = raster[y * width + x];
				file << itoa(pixel.a,shortbuffer,10);
				file << itoa(pixel.r,shortbuffer,10);
				file << itoa(pixel.g,shortbuffer,10);
				file << itoa(pixel.b,shortbuffer,10);
			}
		}

	}
	file.close();