aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore5
-rw-r--r--README.md1
-rw-r--r--main.c10
3 files changed, 10 insertions, 6 deletions
diff --git a/.gitignore b/.gitignore
index 7594bd6..f8dd624 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,3 +1,6 @@
1.DS_Store 1.DS_Store
2*.png
3blpconvert 2blpconvert
3samples/*.png
4samples/*.bmp
5samples/*.jpg
6samples/*.tga
diff --git a/README.md b/README.md
index 62226ce..2321049 100644
--- a/README.md
+++ b/README.md
@@ -54,6 +54,7 @@ Processing File:
54 Folder: samples 54 Folder: samples
55 Filename: Ability_Ambush 55 Filename: Ability_Ambush
56 Extension: .blp 56 Extension: .blp
57 Format: png
57BLP File Details: 58BLP File Details:
58 Type: 1, BLP/DXTC/Uncompressed 59 Type: 1, BLP/DXTC/Uncompressed
59 Compression: 2, DXTC 60 Compression: 2, DXTC
diff --git a/main.c b/main.c
index ab81be0..1b6369c 100644
--- a/main.c
+++ b/main.c
@@ -54,12 +54,12 @@ image_format get_format_type(const char *format) {
54 if (strcasecmp(format, "png") == 0) return PNG; 54 if (strcasecmp(format, "png") == 0) return PNG;
55 if (strcasecmp(format, "bmp") == 0) return BMP; 55 if (strcasecmp(format, "bmp") == 0) return BMP;
56 if (strcasecmp(format, "tga") == 0) return TGA; 56 if (strcasecmp(format, "tga") == 0) return TGA;
57 if (strcasecmp(format, "jpg") == 0 || strcasecmp(format, "jpeg") == 0) return JPG; 57 if (strcasecmp(format, "jpg") == 0) return JPG;
58 return PNG; 58 return PNG;
59} 59}
60 60
61bool is_valid_format(const char *format) { 61bool is_valid_format(const char *format) {
62 const char *valid_formats[] = {"png", "bmp", "tga", "jpg", "jpeg", NULL}; 62 const char *valid_formats[] = {"png", "bmp", "tga", "jpg", NULL};
63 for (const char **f = valid_formats; *f != NULL; f++) { 63 for (const char **f = valid_formats; *f != NULL; f++) {
64 if (strcasecmp(format, *f) == 0) { 64 if (strcasecmp(format, *f) == 0) {
65 return true; 65 return true;
@@ -304,7 +304,7 @@ void decode_dxt_image(const uint8_t *image_data, uint32_t width, uint32_t height
304 } 304 }
305 break; 305 break;
306 case JPG: 306 case JPG:
307 if (verbose) printf("Processing as JPEG format\n"); 307 if (verbose) printf("Processing as JPG format\n");
308 if (stbi_write_jpg(output_filename, width, height, 4, decoded_image, 100) == 0) { 308 if (stbi_write_jpg(output_filename, width, height, 4, decoded_image, 100) == 0) {
309 printf("Failed to write %s file\n", output_filename); 309 printf("Failed to write %s file\n", output_filename);
310 } else { 310 } else {
@@ -425,7 +425,7 @@ void print_help(const char *program_name) {
425 printf(" -h, --help Display this help message\n"); 425 printf(" -h, --help Display this help message\n");
426 printf(" -v, --verbose Enable verbose output\n"); 426 printf(" -v, --verbose Enable verbose output\n");
427 printf(" -f, --format=FORMAT Set output format (default: png)\n"); 427 printf(" -f, --format=FORMAT Set output format (default: png)\n");
428 printf(" Options: png, bmp, tga, jpg, jpeg\n"); 428 printf(" Options: png, bmp, tga, jpg\n");
429} 429}
430 430
431int main(int argc, char *argv[]) { 431int main(int argc, char *argv[]) {
@@ -455,7 +455,7 @@ int main(int argc, char *argv[]) {
455 break; 455 break;
456 case 'f': 456 case 'f':
457 if (!is_valid_format(optarg)) { 457 if (!is_valid_format(optarg)) {
458 fprintf(stderr, "Error: Invalid format '%s'. Valid formats are: png, bmp, tga, jpg, jpeg\n", optarg); 458 fprintf(stderr, "Error: Invalid format '%s'. Valid formats are: png, bmp, tga, jpg\n", optarg);
459 return 1; 459 return 1;
460 } 460 }
461 format = optarg; 461 format = optarg;