Changed Renamed class Bitmap to BitmapImage
~G2k
This commit is contained in:
38
src/bmp.cpp
38
src/bmp.cpp
@@ -26,13 +26,13 @@
|
|||||||
|
|
||||||
namespace OpenArena{
|
namespace OpenArena{
|
||||||
|
|
||||||
Bitmap::Bitmap()
|
BitmapImage::BitmapImage()
|
||||||
{
|
{
|
||||||
Bitmap(1, 1);
|
BitmapImage(1, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Bitmap::Bitmap(uint32 width, uint32 height, uint32 bitsPerPixel, Image::Type type)
|
BitmapImage::BitmapImage(uint32 width, uint32 height, uint32 bitsPerPixel, Image::Type type)
|
||||||
{
|
{
|
||||||
_width = width;
|
_width = width;
|
||||||
_height = height;
|
_height = height;
|
||||||
@@ -41,49 +41,49 @@ namespace OpenArena{
|
|||||||
_data = new uint8[_width * _height * (_bpp >> 3)];
|
_data = new uint8[_width * _height * (_bpp >> 3)];
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap::~Bitmap()
|
BitmapImage::~BitmapImage()
|
||||||
{
|
{
|
||||||
delete [] _data;
|
delete [] _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8 * Bitmap::GetImageData() const
|
uint8 * BitmapImage::GetImageData() const
|
||||||
{
|
{
|
||||||
return _data;
|
return _data;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Bitmap::GetBitsPerPixel() const
|
uint32 BitmapImage::GetBitsPerPixel() const
|
||||||
{
|
{
|
||||||
return _bpp;
|
return _bpp;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Bitmap::GetBytesPerPixel() const
|
uint32 BitmapImage::GetBytesPerPixel() const
|
||||||
{
|
{
|
||||||
return _bpp >> 3;
|
return _bpp >> 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Bitmap::GetWidth() const
|
uint32 BitmapImage::GetWidth() const
|
||||||
{
|
{
|
||||||
return _width;
|
return _width;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32 Bitmap::GetHeight() const
|
uint32 BitmapImage::GetHeight() const
|
||||||
{
|
{
|
||||||
return _height;
|
return _height;
|
||||||
}
|
}
|
||||||
|
|
||||||
Image::Type Bitmap::GetType() const
|
Image::Type BitmapImage::GetType() const
|
||||||
{
|
{
|
||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap* Bitmap::CreateFromFile(const char* filename)
|
BitmapImage* BitmapImage::CreateFromFile(const char* filename)
|
||||||
{
|
{
|
||||||
FILE* file = NULL; //A file from cstdlib?
|
FILE* file = NULL; //A file from cstdlib?
|
||||||
|
|
||||||
//If our filename is null return an empty 1x1 image
|
//If our filename is null return an empty 1x1 image
|
||||||
if(filename == NULL)
|
if(filename == NULL)
|
||||||
{
|
{
|
||||||
return new Bitmap(1,1);
|
return new BitmapImage(1,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Try to open the file
|
//Try to open the file
|
||||||
@@ -92,7 +92,7 @@ namespace OpenArena{
|
|||||||
//If the open failed return an empry 1x1 image
|
//If the open failed return an empry 1x1 image
|
||||||
if(file == NULL)
|
if(file == NULL)
|
||||||
{
|
{
|
||||||
return new Bitmap(1,1);
|
return new BitmapImage(1,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
BITMAP_HEADER bmpHeader;
|
BITMAP_HEADER bmpHeader;
|
||||||
@@ -153,7 +153,7 @@ namespace OpenArena{
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bitmap* image = new Bitmap(bmpInfo.width, bmpInfo.height, bmpInfo.bitCount, (Type)GL_RGB);
|
BitmapImage* image = new BitmapImage(bmpInfo.width, bmpInfo.height, bmpInfo.bitCount, (Type)GL_RGB);
|
||||||
|
|
||||||
numPixels = image->GetWidth() * image->GetHeight();
|
numPixels = image->GetWidth() * image->GetHeight();
|
||||||
|
|
||||||
@@ -237,9 +237,9 @@ namespace OpenArena{
|
|||||||
f=fopen(fn, "rb");
|
f=fopen(fn, "rb");
|
||||||
if(f)
|
if(f)
|
||||||
{
|
{
|
||||||
Bitmap::BITMAP_HEADER bmpHeader;
|
BitmapImage::BITMAP_HEADER bmpHeader;
|
||||||
Bitmap::BITMAP_INFO bmpInfo;
|
BitmapImage::BITMAP_INFO bmpInfo;
|
||||||
Bitmap::BITMAP_QUAD* bmpPallette = NULL;
|
BitmapImage::BITMAP_QUAD* bmpPallette = NULL;
|
||||||
uint32 palletteEntries = 0;
|
uint32 palletteEntries = 0;
|
||||||
|
|
||||||
fread(&bmpHeader, sizeof(bmpHeader), 1, f);
|
fread(&bmpHeader, sizeof(bmpHeader), 1, f);
|
||||||
@@ -312,8 +312,8 @@ namespace OpenArena{
|
|||||||
{
|
{
|
||||||
//Load the pallette
|
//Load the pallette
|
||||||
palletteEntries = bmpInfo.bitCount << 8;
|
palletteEntries = bmpInfo.bitCount << 8;
|
||||||
bmpPallette = new Bitmap::BITMAP_QUAD[palletteEntries];
|
bmpPallette = new BitmapImage::BITMAP_QUAD[palletteEntries];
|
||||||
fread(bmpPallette, sizeof(Bitmap::BITMAP_QUAD), palletteEntries, f);
|
fread(bmpPallette, sizeof(BitmapImage::BITMAP_QUAD), palletteEntries, f);
|
||||||
}
|
}
|
||||||
|
|
||||||
fseek(f, bmpHeader.offset, SEEK_SET);
|
fseek(f, bmpHeader.offset, SEEK_SET);
|
||||||
|
|||||||
10
src/bmp.h
10
src/bmp.h
@@ -8,20 +8,20 @@
|
|||||||
|
|
||||||
namespace OpenArena{
|
namespace OpenArena{
|
||||||
TextureImage* LoadBMP(const char* Filename);
|
TextureImage* LoadBMP(const char* Filename);
|
||||||
class Bitmap :Image
|
class BitmapImage: public Image
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Bitmap();
|
virtual ~BitmapImage();
|
||||||
virtual uint8 * GetImageData() const;
|
virtual uint8 * GetImageData() const;
|
||||||
virtual uint32 GetBitsPerPixel() const;
|
virtual uint32 GetBitsPerPixel() const;
|
||||||
virtual uint32 GetBytesPerPixel() const;
|
virtual uint32 GetBytesPerPixel() const;
|
||||||
virtual uint32 GetWidth() const;
|
virtual uint32 GetWidth() const;
|
||||||
virtual uint32 GetHeight() const;
|
virtual uint32 GetHeight() const;
|
||||||
virtual Image::Type GetType() const;
|
virtual Image::Type GetType() const;
|
||||||
static Bitmap* CreateFromFile(const char* filename);
|
static BitmapImage* CreateFromFile(const char* filename);
|
||||||
private:
|
private:
|
||||||
Bitmap();
|
BitmapImage();
|
||||||
Bitmap(uint32 width, uint32 height, uint32 = 24, Image::Type = Image::Type_RGB);
|
BitmapImage(uint32 width, uint32 height, uint32 = 24, Image::Type = Image::Type_RGB);
|
||||||
uint8* _data;
|
uint8* _data;
|
||||||
uint32 _width;
|
uint32 _width;
|
||||||
uint32 _height;
|
uint32 _height;
|
||||||
|
|||||||
Reference in New Issue
Block a user