From a3df5d9471fd9594cf088c1738c68fdd8c310975 Mon Sep 17 00:00:00 2001 From: "HuYingzhuo(hugo/hyzboy)" Date: Tue, 8 Nov 2022 19:11:55 +0800 Subject: [PATCH] supported convert from alpha channel --- CMakeLists.txt | 14 ++++++++++---- DistanceFieldGenerater.cpp | 24 ++++++++++++++++++++---- ILImage.h | 2 ++ ILImageSupport.cpp | 5 +++++ main.cpp | 2 ++ 5 files changed, 39 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b7861e6..75991ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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() diff --git a/DistanceFieldGenerater.cpp b/DistanceFieldGenerater.cpp index 0918afc..0d4357d 100644 --- a/DistanceFieldGenerater.cpp +++ b/DistanceFieldGenerater.cpp @@ -125,29 +125,45 @@ namespace df int os_main(int argc,os_char **argv) { - std::cout<<"Distance Field Generater v1.0"< failed.")< grid1=new df::Grid(img.width(),img.height()); AutoDelete grid2=new df::Grid(img.width(),img.height()); diff --git a/ILImage.h b/ILImage.h index d3f0ddb..0883889 100644 --- a/ILImage.h +++ b/ILImage.h @@ -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);} diff --git a/ILImageSupport.cpp b/ILImageSupport.cpp index dbaf618..ea475f8 100644 --- a/ILImageSupport.cpp +++ b/ILImageSupport.cpp @@ -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); diff --git a/main.cpp b/main.cpp index 6d834d0..2877772 100644 --- a/main.cpp +++ b/main.cpp @@ -60,6 +60,8 @@ int os_main(int argc,os_char **argv) return 0; } + logger::InitLogger(OS_TEXT("TexConv")); + CmdParse cp(argc,argv); ImageConvertConfig icc;