diff options
| -rw-r--r-- | .gitignore | 5 | ||||
| -rw-r--r-- | README.md | 1 | ||||
| -rw-r--r-- | main.c | 10 |
3 files changed, 10 insertions, 6 deletions
| @@ -1,3 +1,6 @@ | |||
| 1 | .DS_Store | 1 | .DS_Store |
| 2 | *.png | ||
| 3 | blpconvert | 2 | blpconvert |
| 3 | samples/*.png | ||
| 4 | samples/*.bmp | ||
| 5 | samples/*.jpg | ||
| 6 | samples/*.tga | ||
| @@ -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 | ||
| 57 | BLP File Details: | 58 | BLP File Details: |
| 58 | Type: 1, BLP/DXTC/Uncompressed | 59 | Type: 1, BLP/DXTC/Uncompressed |
| 59 | Compression: 2, DXTC | 60 | Compression: 2, DXTC |
| @@ -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 | ||
| 61 | bool is_valid_format(const char *format) { | 61 | bool 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 | ||
| 431 | int main(int argc, char *argv[]) { | 431 | int 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; |
