1# Library usage example 2 3This is a minimal example of using the astcenc codec as a library in another 4project. This sample shows: 5 6 * How to include astcenc as an external project CMake dependency. 7 * How to use the API to compress and decompress an image. 8 9For sake of simplicity the example application uses fixed compression settings, 10reading an uncompressed LDR image, compressing using 6x6 blocks at medium 11quality, and then decompressing and writing the decompressed image back to disk 12as a PNG file. 13 14## Building 15 16:warning: For sake of simplicity the example CMake project uses the CMake 17`ExternalProject` mechanism to import the astcenc project from GitHub. This is 18trivial to integrate, but requires network access during the build to pull the 19astcenc project. 20 21Most users will want to store a copy of astcenc in a project sub-directory, 22e.g. by using git submodules, and then use `add_subdirectory()` to include the 23project in their build. This allows the user to directly use the astcenc core 24library as a link requirement via `target_link_libraries()`, without the 25additional plumbing that `ExternalProject` requires. 26 27### Linux and macOS 28 29From the `./Utils/Example` directory. 30 31``` 32mkdir build 33cd build 34cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release .. 35make -j8 36``` 37 38### Windows 39 40From the `./Utils/Example` directory, in a Visual Studio command prompt. 41 42``` 43mkdir build 44cd build 45cmake -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Release .. 46nmake 47``` 48 49## Running 50 51From the build directory above. 52 53``` 54astcenc_example <input.png> <output.png> 55``` 56