ULRE/src/SceneGraph/Bitmap2DLoader.cpp

45 lines
960 B
C++
Raw Normal View History

2021-12-13 21:03:41 +08:00
#include<hgl/graph/Bitmap2DLoader.h>
namespace hgl
{
namespace graph
{
Bitmap2DLoader::~Bitmap2DLoader()
{
SAFE_CLEAR(bmp);
}
void *Bitmap2DLoader::OnBegin(uint32 total_bytes)
{
SAFE_CLEAR(bmp);
bmp=new BitmapData;
bmp->width =file_header.width;
bmp->height =file_header.height;
bmp->total_bytes=total_bytes;
bmp->data=new char[total_bytes];
return bmp->data;
}
BitmapData *Bitmap2DLoader::GetBitmap()
{
BitmapData *result=bmp;
bmp=nullptr;
return result;
}
BitmapData *LoadBitmapFromFile(const OSString &filename)
{
Bitmap2DLoader loader;
if(!loader.Load(filename))
return(nullptr);
return loader.GetBitmap();
}
}//namespace graph
}//namespace hgl