2019-12-05 10:00:07 +08:00
|
|
|
|
#include"TextureFileCreater.h"
|
2019-12-02 22:10:49 +08:00
|
|
|
|
#include"ILImage.h"
|
|
|
|
|
|
|
|
|
|
class TextureFileCreaterRG:public TextureFileCreater
|
|
|
|
|
{
|
2020-10-25 21:22:18 +08:00
|
|
|
|
ILuint type;
|
|
|
|
|
|
2019-12-02 22:10:49 +08:00
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
using TextureFileCreater::TextureFileCreater;
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
2020-10-25 21:22:18 +08:00
|
|
|
|
bool InitFormat() override
|
2019-12-02 22:10:49 +08:00
|
|
|
|
{
|
2020-10-25 21:22:18 +08:00
|
|
|
|
if(!ToILType(type,pixel_format->bits[0],pixel_format->type))
|
|
|
|
|
return(false);
|
|
|
|
|
|
|
|
|
|
return image->ConvertToRG(type);
|
|
|
|
|
}
|
2019-12-02 22:10:49 +08:00
|
|
|
|
|
2020-10-25 21:22:18 +08:00
|
|
|
|
uint32 Write() override
|
|
|
|
|
{
|
|
|
|
|
const uint total_bytes=(pixel_format->total_bits*image->pixel_total())>>3;
|
|
|
|
|
|
|
|
|
|
std::cout<<"Convert Image To: "<<image->width()<<"x"<<image->height()<<" "<<total_bytes<<" bytes."<<std::endl;
|
2019-12-02 22:10:49 +08:00
|
|
|
|
|
|
|
|
|
void *data=image->GetRG(type);
|
|
|
|
|
|
|
|
|
|
//目前仅有R8UN,R16UN,R16F,R32U,R32I,R32F几种,都是8的整倍数,所以直接写
|
2019-12-05 10:00:07 +08:00
|
|
|
|
|
2020-10-25 21:22:18 +08:00
|
|
|
|
return TextureFileCreater::Write(data,total_bytes);
|
2019-12-02 22:10:49 +08:00
|
|
|
|
}
|
|
|
|
|
};//class TextureFileCreaterRG:public TextureFileCreater
|
|
|
|
|
|
|
|
|
|
TextureFileCreater *CreateTextureFileCreaterRG(const PixelFormat *pf,ILImage *image)
|
|
|
|
|
{
|
|
|
|
|
return(new TextureFileCreaterRG(pf,image));
|
|
|
|
|
}
|