move Bitmap2DLoader codes to TextureLoader.h
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include<hgl/io/InputStream.h>
|
#include<hgl/io/InputStream.h>
|
||||||
#include<hgl/type/BaseString.h>
|
#include<hgl/type/BaseString.h>
|
||||||
|
#include<hgl/graph/Bitmap.h>
|
||||||
namespace hgl
|
namespace hgl
|
||||||
{
|
{
|
||||||
namespace graph
|
namespace graph
|
||||||
@@ -54,6 +55,27 @@ namespace hgl
|
|||||||
bool Load(io::InputStream *is);
|
bool Load(io::InputStream *is);
|
||||||
bool Load(const OSString &filename);
|
bool Load(const OSString &filename);
|
||||||
};//class Texture2DLoader
|
};//class Texture2DLoader
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 2D位图加载
|
||||||
|
*/
|
||||||
|
class Bitmap2DLoader:public Texture2DLoader
|
||||||
|
{
|
||||||
|
protected:
|
||||||
|
|
||||||
|
BitmapData *bmp=nullptr;
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
~Bitmap2DLoader();
|
||||||
|
|
||||||
|
void *OnBegin(uint32 total_bytes) override;
|
||||||
|
void OnEnd() override {}
|
||||||
|
|
||||||
|
BitmapData *GetBitmap();
|
||||||
|
};//class Bitmap2DLoader
|
||||||
|
|
||||||
|
BitmapData *LoadBitmapFromFile(const OSString &filename);
|
||||||
}//namespace graph
|
}//namespace graph
|
||||||
}//namespace hgl
|
}//namespace hgl
|
||||||
#endif//HGL_GRAPH_TEXTURE_LOADER_INCLUDE
|
#endif//HGL_GRAPH_TEXTURE_LOADER_INCLUDE
|
||||||
|
@@ -53,21 +53,15 @@ namespace hgl
|
|||||||
|
|
||||||
namespace graph
|
namespace graph
|
||||||
{
|
{
|
||||||
class Bitmap2DLoader:public Texture2DLoader
|
Bitmap2DLoader::~Bitmap2DLoader()
|
||||||
{
|
|
||||||
protected:
|
|
||||||
|
|
||||||
BitmapData *bmp=nullptr;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
~Bitmap2DLoader()
|
|
||||||
{
|
{
|
||||||
SAFE_CLEAR(bmp);
|
SAFE_CLEAR(bmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *OnBegin(uint32 total_bytes) override
|
void *Bitmap2DLoader::OnBegin(uint32 total_bytes)
|
||||||
{
|
{
|
||||||
|
SAFE_CLEAR(bmp);
|
||||||
|
|
||||||
bmp=new BitmapData;
|
bmp=new BitmapData;
|
||||||
|
|
||||||
bmp->width =file_header.width;
|
bmp->width =file_header.width;
|
||||||
@@ -79,15 +73,12 @@ namespace hgl
|
|||||||
return bmp->data;
|
return bmp->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnEnd() override {}
|
BitmapData *Bitmap2DLoader::GetBitmap()
|
||||||
|
|
||||||
BitmapData *GetBitmap()
|
|
||||||
{
|
{
|
||||||
BitmapData *result=bmp;
|
BitmapData *result=bmp;
|
||||||
bmp=nullptr;
|
bmp=nullptr;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
};//class Bitmap2DLoader
|
|
||||||
|
|
||||||
BitmapData *LoadBitmapFromFile(const OSString &filename)
|
BitmapData *LoadBitmapFromFile(const OSString &filename)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user