| 68 | } |
| 69 | |
| 70 | int main(int argc, char* argv[]) |
| 71 | { |
| 72 | #ifdef _WIN32 |
| 73 | double start_time = timeStampsec(); |
| 74 | #endif |
| 75 | if (argc < 5) |
| 76 | { |
| 77 | std::printf("Example1 SourceFile DestFile Format Quality\n"); |
| 78 | std::printf("This example shows how to compress a single image by generating mipmap levels\n"); |
| 79 | std::printf("then compressing it using the compression format and quality settings\n"); |
| 80 | std::printf("Quality is in the range of 0.0 to 1.0\n"); |
| 81 | std::printf("When using DLL builds make sure the CMP_Framework_xx_DLL.dll is in exe path\n"); |
| 82 | std::printf("Usage: Example1.exe ruby.dds ruby_bc7.dds BC7 0.05\n"); |
| 83 | std::printf("this will generate a mip mapped compressed ruby file in BC7 format\n"); |
| 84 | return 0; |
| 85 | } |
| 86 | |
| 87 | const char* pszSourceFile = argv[1]; |
| 88 | const char* pszDestFile = argv[2]; |
| 89 | CMP_FORMAT destFormat = CMP_ParseFormat(argv[3]); |
| 90 | CMP_ERROR cmp_status; |
| 91 | CMP_FLOAT fQuality; |
| 92 | |
| 93 | try |
| 94 | { |
| 95 | fQuality = std::stof(argv[4]); |
| 96 | if (fQuality < 0.0f) |
| 97 | { |
| 98 | fQuality = 0.0f; |
| 99 | std::printf("Warning: Quality setting is out of range using 0.0\n"); |
| 100 | } |
| 101 | if (fQuality > 1.0f) |
| 102 | { |
| 103 | fQuality = 1.0f; |
| 104 | std::printf("Warning: Quality setting is out of range using 1.0\n"); |
| 105 | } |
| 106 | } |
| 107 | catch (...) |
| 108 | { |
| 109 | std::printf("Error: Unable to process quality setting\n"); |
| 110 | return -1; |
| 111 | } |
| 112 | |
| 113 | if (destFormat == CMP_FORMAT_Unknown) |
| 114 | { |
| 115 | std::printf("Error: Unsupported destination format\n"); |
| 116 | return 0; |
| 117 | } |
| 118 | |
| 119 | //-------------------------- |
| 120 | // Init frameworks |
| 121 | // plugin and IO interfaces |
| 122 | //-------------------------- |
| 123 | CMP_InitFramework(); |
| 124 | |
| 125 | //--------------- |
| 126 | // Load the image |
| 127 | //--------------- |
nothing calls this directly
no test coverage detected