From 97cb538d7cec448c8be2d97a413e6002f0518530 Mon Sep 17 00:00:00 2001 From: meh2481 Date: Fri, 4 Jul 2014 22:34:10 -0400 Subject: [PATCH] Figure out image type=2 --- Makefile.unix | 12 ++++++++++-- main.cpp | 22 +++++++++++----------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/Makefile.unix b/Makefile.unix index 5e6703f..55a3aae 100644 --- a/Makefile.unix +++ b/Makefile.unix @@ -4,13 +4,21 @@ LIB = -lsquish -lfreeimage HEADERPATH = -I./include STATICGCC = -static-libgcc -static-libstdc++ +ifeq ($(BUILD),release) +# "Release" build - optimization, and no debug symbols + CXXFLAGS += -O2 -Os -s -DNDEBUG +else +# "Debug" build - no optimization, and debugging symbols + CXXFLAGS += -g -ggdb -DDEBUG +endif + all : wfLZEx wfLZEx : $(objects) - g++ -Wall -O2 -s -o $@ $(objects) $(LIBPATH) $(LIB) $(STATICGCC) $(HEADERPATH) + g++ $(CXXFLAGS) -o $@ $(objects) $(LIBPATH) $(LIB) $(STATICGCC) $(HEADERPATH) %.o: %.cpp - g++ -O2 -c -MMD -s -o $@ $< $(HEADERPATH) + g++ $(CXXFLAGS) -c -MMD -o $@ $< $(HEADERPATH) -include $(objects:.o=.d) diff --git a/main.cpp b/main.cpp index 6970ccb..0cad79f 100644 --- a/main.cpp +++ b/main.cpp @@ -2,6 +2,7 @@ #include #include #include +#include #include #include #include @@ -59,10 +60,10 @@ typedef struct } PiecesDesc; #define TEXTURE_TYPE_UNKNOWN1 1 -#define TEXTURE_TYPE_UNCOMPRESSED 2 -#define TEXTURE_TYPE_DXT5_COL 3 -#define TEXTURE_TYPE_DXT1_COL_MUL 5 -#define TEXTURE_TYPE_DXT5_COL_DXT1_MUL 6 +#define TEXTURE_TYPE_DXT1_COL 2 //squish::kDxt1 color, no multiply +#define TEXTURE_TYPE_DXT5_COL 3 //squish::kDxt5 color, no multiply +#define TEXTURE_TYPE_DXT1_COL_MUL 5 //squish::kDxt1 color and squish::kDxt1 multiply +#define TEXTURE_TYPE_DXT5_COL_DXT1_MUL 6 //squish::kDxt5 color and squish::kDxt1 multiply int powerof2(int orig) { @@ -301,22 +302,21 @@ int splitImages(const char* cFilename) //Create color image color = (uint8_t*)malloc(decompressedSize * 8); if(!g_bMulOnly) - squish::DecompressImage( color, th.width, th.height, dst, g_DecompressFlags ); + squish::DecompressImage( color, th.width, th.height, dst, squish::kDxt1 ); //Create multiply image mul = (uint8_t*)malloc(decompressedSize * 8); if(!g_bColOnly) - squish::DecompressImage( mul, th.width, th.height, dst + decompressedSize/2, g_DecompressFlags ); //Second image starts halfway through decompressed data + squish::DecompressImage( mul, th.width, th.height, dst + decompressedSize/2, squish::kDxt1 ); //Second image starts halfway through decompressed data } - else if(th.type == TEXTURE_TYPE_UNCOMPRESSED) + else if(th.type == TEXTURE_TYPE_DXT1_COL) { - color = (uint8_t*)malloc(th.width * th.height * 4); - uint8_t* dest_ptr = color; - for(uint32_t ctr = 0; ctr < th.width * th.height * 4; ctr++) - *dest_ptr++ = dst[ctr]; + color = (uint8_t*)malloc(decompressedSize * 8); + squish::DecompressImage(color, th.width, th.height, dst, squish::kDxt1); } else { + cout << "Decomp size: " << decompressedSize << ", w*h: " << th.width << "," << th.height << endl; cout << "Warning: skipping unknown image type " << th.type << endl; delete dst; continue;