Skip to content

Commit

Permalink
Figure out image type=2
Browse files Browse the repository at this point in the history
  • Loading branch information
meh2481 committed Jul 5, 2014
1 parent 2053716 commit 97cb538
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 13 deletions.
12 changes: 10 additions & 2 deletions Makefile.unix
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
22 changes: 11 additions & 11 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <stdlib.h>
#include <cstdio>
#include <squish.h>
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 97cb538

Please sign in to comment.