mirror of
https://github.com/yuzu-emu/FasTC.git
synced 2024-11-27 19:04:20 +01:00
Add hooks to support filenames with .ktx extension
This commit is contained in:
parent
552b8440b1
commit
1b5b8c3900
@ -77,7 +77,7 @@ void PrintUsage() {
|
||||
fprintf(stderr, "\t-v\t\tVerbose mode: prints out Entropy, Mean Local Entropy, and MSSIM\n");
|
||||
fprintf(stderr, "\t-f <fmt>\tFormat to use. Either \"BPTC\", \"ETC1\", \"DXT1\", \"DXT5\", or \"PVRTC\". Default: BPTC\n");
|
||||
fprintf(stderr, "\t-l\t\tSave an output log.\n");
|
||||
fprintf(stderr, "\t-d <file>\tSpecify decompressed output (currently only png files supported, default: basename-<fmt>.png)\n");
|
||||
fprintf(stderr, "\t-d <file>\tSpecify decompressed output (default: basename-<fmt>.png)\n");
|
||||
fprintf(stderr, "\t-nd\t\tSuppress decompressed output\n");
|
||||
fprintf(stderr, "\t-q <quality>\tSet compression quality level. Default: 50\n");
|
||||
fprintf(stderr, "\t-n <num>\tCompress the image num times and give the average time and PSNR. Default: 1\n");
|
||||
@ -350,7 +350,8 @@ int main(int argc, char **argv) {
|
||||
strcat(basename, "-etc1.png");
|
||||
}
|
||||
|
||||
ImageFile cImgFile (basename, eFileFormat_PNG, *ci);
|
||||
EImageFileFormat fmt = ImageFile::DetectFileFormat(basename);
|
||||
ImageFile cImgFile (basename, fmt, *ci);
|
||||
cImgFile.Write();
|
||||
}
|
||||
|
||||
|
@ -119,6 +119,7 @@ ADD_LIBRARY(FasTCIO
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES( FasTCIO FasTCBase )
|
||||
TARGET_LINK_LIBRARIES( FasTCIO FasTCCore )
|
||||
|
||||
IF( PNG_FOUND )
|
||||
TARGET_LINK_LIBRARIES( FasTCIO ${PNG_LIBRARY} )
|
||||
|
@ -70,6 +70,7 @@ public:
|
||||
|
||||
~ImageFile();
|
||||
|
||||
static EImageFileFormat DetectFileFormat(const CHAR *filename);
|
||||
unsigned int GetWidth() const { return m_Width; }
|
||||
unsigned int GetHeight() const { return m_Height; }
|
||||
FasTC::Image<> *GetImage() const { return m_Image; }
|
||||
@ -98,7 +99,6 @@ public:
|
||||
|
||||
bool ReadFileData(const CHAR *filename);
|
||||
static bool WriteImageDataToFile(const uint8 *data, const uint32 dataSz, const CHAR *filename);
|
||||
static EImageFileFormat DetectFileFormat(const CHAR *filename);
|
||||
|
||||
FasTC::Image<> *LoadImage() const;
|
||||
};
|
||||
|
@ -48,6 +48,7 @@ enum EImageFileFormat {
|
||||
eFileFormat_PNG,
|
||||
eFileFormat_PVR,
|
||||
eFileFormat_TGA,
|
||||
eFileFormat_KTX,
|
||||
|
||||
kNumImageFileFormats
|
||||
};
|
||||
|
@ -67,6 +67,9 @@
|
||||
|
||||
#include "ImageLoaderTGA.h"
|
||||
|
||||
#include "ImageLoaderKTX.h"
|
||||
#include "ImageWriterKTX.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Static helper functions
|
||||
@ -162,6 +165,10 @@ bool ImageFile::Write() {
|
||||
break;
|
||||
#endif // PNG_FOUND
|
||||
|
||||
case eFileFormat_KTX:
|
||||
writer = new ImageWriterKTX(*m_Image);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unable to write image: unknown file format.\n");
|
||||
return false;
|
||||
@ -202,6 +209,10 @@ FasTC::Image<> *ImageFile::LoadImage() const {
|
||||
loader = new ImageLoaderTGA(m_FileData, m_FileDataSz);
|
||||
break;
|
||||
|
||||
case eFileFormat_KTX:
|
||||
loader = new ImageLoaderKTX(m_FileData, m_FileDataSz);
|
||||
break;
|
||||
|
||||
default:
|
||||
fprintf(stderr, "Unable to load image: unknown file format.\n");
|
||||
return NULL;
|
||||
@ -265,6 +276,9 @@ EImageFileFormat ImageFile::DetectFileFormat(const CHAR *filename) {
|
||||
else if(strcmp(ext, ".tga") == 0) {
|
||||
return eFileFormat_TGA;
|
||||
}
|
||||
else if(strcmp(ext, ".ktx") == 0) {
|
||||
return eFileFormat_KTX;
|
||||
}
|
||||
|
||||
return kNumImageFileFormats;
|
||||
}
|
||||
|
@ -86,7 +86,6 @@ ADD_LIBRARY( PVRTCEncoder
|
||||
)
|
||||
|
||||
TARGET_LINK_LIBRARIES( PVRTCEncoder FasTCBase )
|
||||
TARGET_LINK_LIBRARIES( PVRTCEncoder FasTCCore )
|
||||
TARGET_LINK_LIBRARIES( PVRTCEncoder FasTCIO )
|
||||
|
||||
IF( PVRTEXLIB_FOUND )
|
||||
|
Loading…
Reference in New Issue
Block a user