diff --git a/interface/java_binding/src/main/cpp/KtxTexture2.cpp b/interface/java_binding/src/main/cpp/KtxTexture2.cpp index e6df2ee8ba..5e6f5a1433 100644 --- a/interface/java_binding/src/main/cpp/KtxTexture2.cpp +++ b/interface/java_binding/src/main/cpp/KtxTexture2.cpp @@ -133,4 +133,16 @@ extern "C" JNIEXPORT jobject JNICALL Java_org_khronos_ktx_KtxTexture2_createFrom return make_ktx2_wrapper(env, instance); } +extern "C" JNIEXPORT jint JNICALL Java_org_khronos_ktx_KtxTexture2_deflateZstd(JNIEnv *env, + jobject thiz, + jint level) +{ + return ktxTexture2_DeflateZstd(get_ktx2_texture(env, thiz), static_cast(level)); +} +extern "C" JNIEXPORT jint JNICALL Java_org_khronos_ktx_KtxTexture2_deflateZLIB(JNIEnv *env, + jobject thiz, + jint level) +{ + return ktxTexture2_DeflateZLIB(get_ktx2_texture(env, thiz), static_cast(level)); +} diff --git a/interface/java_binding/src/main/java/org/khronos/ktx/KtxTexture2.java b/interface/java_binding/src/main/java/org/khronos/ktx/KtxTexture2.java index 048b113d3b..a7aa577514 100644 --- a/interface/java_binding/src/main/java/org/khronos/ktx/KtxTexture2.java +++ b/interface/java_binding/src/main/java/org/khronos/ktx/KtxTexture2.java @@ -45,4 +45,30 @@ public static native KtxTexture2 createFromNamedFile(String filename, public static KtxTexture2 createFromNamedFile(String filename) { return createFromNamedFile(filename, KtxTextureCreateFlagBits.LOAD_IMAGE_DATA_BIT); } + + /** + * Deflate the data in a {@link KtxTexture2} object using Zstandard. + * + * The texture's levelIndex, dataSize, DFD, data pointer, and supercompressionScheme will + * all be updated after successful deflation to reflect the deflated data. + * + * @param level Set speed vs compression ratio trade-off. Values + * between 1 and 22 are accepted. The lower the level the faster. Values + * above 20 should be used with caution as they require more memory. + * @return A {@link KtxErrorCode} value + */ + public native int deflateZstd(int level); + + /** + * Deflate the data in a {@link KtxTexture2} object using miniz (ZLIB) + * + * The texture's levelIndex, dataSize, DFD, data pointer, and supercompressionScheme will + * all be updated after successful deflation to reflect the deflated data. + * + * @param level Set speed vs compression ratio trade-off. Values + * between 1 and 9 are accepted. The lower the level the faster. + * @return A {@link KtxErrorCode} value + */ + public native int deflateZLIB(int level); + } diff --git a/lib/texture2.c b/lib/texture2.c index c3aa436d71..8107c4b664 100644 --- a/lib/texture2.c +++ b/lib/texture2.c @@ -2471,7 +2471,7 @@ ktx_uint64_t ktxTexture2_levelDataOffset(ktxTexture2* This, ktx_uint32_t level) * @~English * @brief Inflate the data in a ktxTexture2 object using Zstandard. * - * The texture's levelIndex, dataSize, DFD and supercompressionScheme will + * The texture's levelIndex, dataSize, DFD, data pointer, and supercompressionScheme will * all be updated after successful inflation to reflect the inflated data. * * @param[in] This pointer to the ktxTexture2 object of interest. @@ -2583,7 +2583,7 @@ ktxTexture2_inflateZstdInt(ktxTexture2* This, ktx_uint8_t* pDeflatedData, * @~English * @brief Inflate the data in a ktxTexture2 object using miniz (ZLIB). * - * The texture's levelIndex, dataSize, DFD and supercompressionScheme will + * The texture's levelIndex, dataSize, DFD, data pointer, and supercompressionScheme will * all be updated after successful inflation to reflect the inflated data. * * @param[in] This pointer to the ktxTexture2 object of interest. diff --git a/lib/writer2.c b/lib/writer2.c index e886fb31d4..f90e1c401f 100644 --- a/lib/writer2.c +++ b/lib/writer2.c @@ -761,7 +761,7 @@ ktxTexture2_WriteToMemory(ktxTexture2* This, * @~English * @brief Deflate the data in a ktxTexture2 object using Zstandard. * - * The texture's levelIndex, dataSize, DFD and supercompressionScheme will + * The texture's levelIndex, dataSize, DFD, data pointer, and supercompressionScheme will * all be updated after successful deflation to reflect the deflated data. * * @param[in] This pointer to the ktxTexture2 object of interest. @@ -890,7 +890,7 @@ ktxTexture2_DeflateZstd(ktxTexture2* This, ktx_uint32_t compressionLevel) * @~English * @brief Deflate the data in a ktxTexture2 object using miniz (ZLIB). * - * The texture's levelIndex, dataSize, DFD and supercompressionScheme will + * The texture's levelIndex, dataSize, DFD, data pointer, and supercompressionScheme will * all be updated after successful deflation to reflect the deflated data. * * @param[in] This pointer to the ktxTexture2 object of interest.