This commit is contained in:
hyzboy 2020-08-08 22:20:46 +08:00
parent f284934d81
commit 0a3c620c0b
6 changed files with 41 additions and 20 deletions

View File

@ -51,9 +51,7 @@ public:
void *GetRG(ILuint type){return GetData(IL_LUMINANCE_ALPHA,type);}
void *GetRGB(ILuint type){return GetData(IL_RGB,type);}
// void *GetBGR(ILuint type){return GetData(IL_BGR,type);}
void *GetRGBA(ILuint type){return GetData(IL_RGBA,type);}
// void *GetBGRA(ILuint type){return GetData(IL_BGRA,type);}
void *GetRGBA(ILuint type);
void *GetLum(ILuint type){return GetData(IL_LUMINANCE,type);}
};//class ILImage

View File

@ -240,3 +240,30 @@ void *ILImage::GetData(ILuint format,ILuint type)
return ilGetData();
}
template<typename T> void MixRGBA(T *rgba,T *alpha,int size)
{
int i;
for(i=0;i<size;i++)
{
rgba+=3;
*rgba++=*alpha++;
}
}
void *ILImage::GetRGBA(ILuint type)
{
void *data=GetData(IL_RGBA,type);
void *alpha=ilGetAlpha(type);
const int size=il_width*il_height;
if(type==IL_UNSIGNED_BYTE ||type==IL_BYTE )MixRGBA<uint8 >((uint8 *)data,(uint8 *)alpha,size);else
if(type==IL_UNSIGNED_SHORT ||type==IL_SHORT||type==IL_HALF )MixRGBA<uint16>((uint16 *)data,(uint16 *)alpha,size);else
if(type==IL_UNSIGNED_INT ||type==IL_INT ||type==IL_FLOAT)MixRGBA<uint32>((uint32 *)data,(uint32 *)alpha,size);else
if(type==IL_DOUBLE )MixRGBA<uint64>((uint64 *)data,(uint64 *)alpha,size);else
return(nullptr);
return data;
}

View File

@ -104,7 +104,7 @@ bool TextureFileCreater::Write(void *data)
if(fmt->format>ColorFormat::COMPRESS)
{
dos->WriteUint8(0);
dos->WriteUint16(uint(fmt->format)-uint(ColorFormat::COMPRESS));
dos->WriteUint32(uint(fmt->format)-uint(ColorFormat::COMPRESS));
dos->WriteUint32(total_bytes);
}
else

View File

@ -1,8 +1,8 @@
#include"TextureFileCreater.h"
#include"ILImage.h"
#include<hgl/log/LogInfo.h>
#include<CMP_CompressonatorLib/Common.h>
#include<CMP_CompressonatorLib/Compressonator.h>
#include"CMP_CompressonatorLib/Common.h"
#include"CMP_CompressonatorLib/Compressonator.h"
void CMP_RegisterHostPlugins();
CMP_ERROR CMP_API CMP_DestroyComputeLibrary(bool forceclose = false);
@ -25,7 +25,7 @@ public:
const int channels=image->channels();
const int type=image->type();
memset(&MipSetIn, 0, sizeof(MipSet));
hgl_zero(MipSetIn);
CMP_ChannelFormat cf;
CMP_TextureDataType tdt;
@ -126,7 +126,7 @@ public:
}
MipSetIn.m_nMipLevels = 1;
MipSetIn.m_format = CMP_FORMAT_RGBA_8888;
MipSetIn.m_format = fmt;
CMP_BYTE* pData = CMips.GetMipLevel(&MipSetIn,0)->m_pbData;
@ -144,12 +144,11 @@ public:
void InitOption()
{
memset(&kernel_options,0,sizeof(KernelOptions));
hgl_zero(kernel_options);
constexpr CMP_FORMAT fmt_list[]=
{
CMP_FORMAT_BC1, //ColorFormat::BC1RGB
CMP_FORMAT_BC1, //ColorFormat::BC1RGBA
CMP_FORMAT_BC1, //ColorFormat::BC1
CMP_FORMAT_BC2, //ColorFormat::BC2
CMP_FORMAT_BC3, //ColorFormat::BC3
CMP_FORMAT_BC4, //ColorFormat::BC4
@ -161,8 +160,7 @@ public:
constexpr char fmt_name_list[][8]=
{
"BC1RGB",
"BC1RGBA",
"BC1",
"BC2",
"BC3",
"BC4",
@ -172,14 +170,14 @@ public:
"BC7"
};
const int fmt_index=size_t(fmt->format)-size_t(ColorFormat::BC1RGB);
const int fmt_index=size_t(fmt->format)-size_t(ColorFormat::BC1);
kernel_options.height =image->height();
kernel_options.width =image->width();
kernel_options.fquality =1.0f;
kernel_options.format =fmt_list[fmt_index];
kernel_options.encodeWith =CMP_HPC;
kernel_options.threads =4;
kernel_options.threads =8;
kernel_options.getPerfStats =false;
kernel_options.getDeviceInfo=false;
@ -199,7 +197,7 @@ public:
CMP_RegisterHostPlugins();
CMP_InitializeBCLibrary();
memset(&MipSetOut,0,sizeof(MipSet));
hgl_zero(MipSetOut);
CMP_ProcessTexture(&MipSetIn,&MipSetOut,kernel_options,&TextureFileCreaterCompress::CMP_Feedback_Proc);

View File

@ -51,8 +51,7 @@ namespace hgl
{ColorFormat::COMPRESS, "COMPRESS", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0},ColorDataType::NONE},
{ColorFormat::BC1RGB, "BC1RGB", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0},ColorDataType::NONE},
{ColorFormat::BC1RGBA, "BC1RGBA", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0},ColorDataType::NONE},
{ColorFormat::BC1, "BC1", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0},ColorDataType::NONE},
{ColorFormat::BC2, "BC2", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0},ColorDataType::NONE},
{ColorFormat::BC3, "BC3", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0},ColorDataType::NONE},
{ColorFormat::BC4, "BC4", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0},ColorDataType::NONE},

View File

@ -37,8 +37,7 @@ enum class ColorFormat
COMPRESS,
BC1RGB,
BC1RGBA,
BC1,
BC2,
BC3,
BC4,