supported convert from alpha channel
This commit is contained in:
parent
148eca854f
commit
a3df5d9471
@ -5,11 +5,18 @@ project(TexConv)
|
||||
add_definitions(-DUNICODE -D_UNICODE)
|
||||
|
||||
if(WIN32)
|
||||
find_package(DevIL)
|
||||
|
||||
include_directories(${IL_INCLUDE_DIR})
|
||||
include_directories("${CMAKE_CURRENT_SOURCE_DIR}/DevIL Windows SDK/include")
|
||||
|
||||
SET(HGL_DEVIL_LIB ${IL_LIBRARIES} ${ILU_LIBRARIES})
|
||||
IF(HGL_BITS EQUAL 32)
|
||||
SET(DEVIL_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/DevIL Windows SDK/lib/x86/unicode/Release")
|
||||
else()
|
||||
SET(DEVIL_LIBRARY_PATH "${CMAKE_CURRENT_SOURCE_DIR}/DevIL Windows SDK/lib/x64/unicode/Release")
|
||||
endif()
|
||||
|
||||
SET(HGL_DEVIL_LIB ${DEVIL_LIBRARY_PATH}/DevIL.lib
|
||||
${DEVIL_LIBRARY_PATH}/ILU.lib
|
||||
${DEVIL_LIBRARY_PATH}/ILUT.lib)
|
||||
endif(WIN32)
|
||||
|
||||
include_directories(CMP_CompressonatorLib)
|
||||
@ -89,7 +96,6 @@ target_link_libraries(ComboTexture PRIVATE CMCore CMPlatform CMUtil ${HGL_DEVIL_
|
||||
add_executable(DFGen DistanceFieldGenerater.cpp ILImage.h ILImageSupport.cpp)
|
||||
target_link_libraries(DFGen PRIVATE CMCore CMPlatform CMUtil ${HGL_DEVIL_LIB})
|
||||
|
||||
|
||||
macro(texture_tool_project project_name)
|
||||
set_property(TARGET ${project_name} PROPERTY FOLDER "CM/Tools/Texture")
|
||||
endmacro()
|
||||
|
@ -125,29 +125,45 @@ namespace df
|
||||
|
||||
int os_main(int argc,os_char **argv)
|
||||
{
|
||||
std::cout<<"Distance Field Generater v1.0"<<std::endl<<std::endl;
|
||||
os_out<<OS_TEXT("Distance Field Generater v1.1")<<std::endl;
|
||||
os_out<<std::endl;
|
||||
|
||||
if(argc<2)
|
||||
{
|
||||
std::cout<<"example: DFGen 1.png"<<std::endl<<std::endl;
|
||||
os_out<<OS_TEXT("example: DFGen 1.png [alpha]")<<std::endl<<std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
logger::InitLogger(OS_TEXT("DFGen"));
|
||||
|
||||
ilInit();
|
||||
|
||||
ILImage img;
|
||||
bool use_alpha=false;
|
||||
|
||||
if(!img.LoadFile(argv[1]))
|
||||
{
|
||||
std::cerr<<"open file failed."<<std::endl;
|
||||
os_err<<OS_TEXT("open file <")<<argv[1]<<OS_TEXT("> failed.")<<std::endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(img.channels()==1)
|
||||
{
|
||||
}
|
||||
else
|
||||
if(img.channels()==4)
|
||||
{
|
||||
if(argc==3)
|
||||
{
|
||||
if(argv[2][0]=='a'
|
||||
||argv[2][0]=='A')
|
||||
use_alpha=true;
|
||||
}
|
||||
}
|
||||
|
||||
const uint8 *op=(const uint8 *)img.ToGray();
|
||||
os_out <<(use_alpha?OS_TEXT("use alpha data."):OS_TEXT("use luminance data."))<<std::endl;
|
||||
|
||||
const uint8 *op=(const uint8 *)(use_alpha?img.GetAlpha(IL_UNSIGNED_BYTE):img.ToGray());
|
||||
|
||||
AutoDelete<df::Grid> grid1=new df::Grid(img.width(),img.height());
|
||||
AutoDelete<df::Grid> grid2=new df::Grid(img.width(),img.height());
|
||||
|
@ -62,6 +62,8 @@ public:
|
||||
|
||||
void *GetLum(ILuint type){return GetData(IL_LUMINANCE,type);}
|
||||
|
||||
void *GetAlpha(ILuint type);
|
||||
|
||||
bool ConvertToR(ILuint type){return (il_format==IL_LUMINANCE?Convert(IL_LUMINANCE,type):Convert(IL_ALPHA,type));}
|
||||
bool ConvertToRG(ILuint type){return Convert(IL_LUMINANCE_ALPHA,type);}
|
||||
bool ConvertToRGB(ILuint type){return Convert(IL_RGB,type);}
|
||||
|
@ -343,6 +343,11 @@ void *ILImage::ToGray(ILuint type)
|
||||
return ilGetData();
|
||||
}
|
||||
|
||||
void *ILImage::GetAlpha(ILuint type)
|
||||
{
|
||||
return ilGetAlpha(type);
|
||||
}
|
||||
|
||||
void *ILImage::GetR(ILuint type)
|
||||
{
|
||||
if(il_format==IL_ALPHA)return ilGetAlpha(type);
|
||||
|
Loading…
x
Reference in New Issue
Block a user