All pastes #897772 Raw Edit

Someone

public text v1 · immutable
·published 2008-02-09 20:50 UTC
rendered paste body
#ifndef bmploader_hpp__
#define bmploader_hpp__

#include "FileIO.hpp"

class BMPClass
{
private:
	union
	{
		short int si[2];
		int i;
		char c[4];
	};
	int iHeight;
	int iWidth;
	int iSize;
	FileIO BMPFile;
public:
	char *cpData;
	bool LoadBMP(char *cpAddress);
};

bool BMPClass::LoadBMP(char *cpAddress)
{
	int iReadLoc;
	int iI;

	BMPFile.Open(cpAddress);
	BMPFile.Read(2,c,0);
	//Checks If file is BM
	if(si[0] != 19778)
		return false;
	BMPFile.Read(2,c,6);
	if(!si[0])
		return false;
	BMPFile.Read(2,c,8);
	if(!si[0])
		return false;
	//Gets Width + Height
	BMPFile.Read(4,c,18);
	iWidth = i;
	BMPFile.Read(4,c,22);
	iHeight = i;
	//Gets Data starting location
	BMPFile.Read(4,c,10);
	iReadLoc = i;
	cpData = new char[iWidth*iHeight*3];
	iI = 0;
	while(iI < iWidth*iHeight)
	{
		BMPFile.Read(3,c,iReadLoc);
		cpData[iI*3] = c[0];
		cpData[iI*3+1] = c[1];
		cpData[iI*3+2] = c[2];
		iI++;
		iReadLoc += 4;
	}
	return true;
}
#endif