1
| |
#include "BMPLoader.h"
BMPClass::BMPClass(){bytes=0;}
BMPClass::~BMPClass(){delete[] bytes;}
BYTE& BMPClass::pixel(int x,int y,int c){return bytes[(y*width+x)*3+c];}
void BMPClass::allocateMem(){delete[] bytes;bytes=new BYTE[width*height*3];}
std::string TranslateBMPError(BMPError err)
{
switch(err)
{
case(BMPNOTABITMAP):
return "This file is not a bitmap, specifically it doesn't start 'BM'";
case(BMPNOOPEN):
return "Failed to open the file, suspect it doesn't exist";
case(BMPFILEERROR):
return "Some kind of error while physically reading the file";
case(BMPNOERROR):
return "No errors detected";
case(BMPUNKNOWNFORMAT):
return "Unknown bmp format, ie not 24bit, 256,16 or 2 colour";
default:
return "Not a valid error code";
}
}
BMPError BMPLoad(std::string fname,BMPClass& bmp)
{
FILE * f=fopen(fname.c_str(),"rb"); |