Skip to content

Commit

Permalink
feat(tinyexr): update to latest version
Browse files Browse the repository at this point in the history
  • Loading branch information
Spasi committed Sep 18, 2022
1 parent 6bd6447 commit 3bbf3ad
Show file tree
Hide file tree
Showing 4 changed files with 372 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ JNIEXPORT jint JNICALL Java_org_lwjgl_util_tinyexr_TinyEXR_nEXRLayers(JNIEnv *__
return (jint)EXRLayers(filename, layer_names, num_layers, err);
}

JNIEXPORT jint JNICALL Java_org_lwjgl_util_tinyexr_TinyEXR_nIsEXRFromMemory(JNIEnv *__env, jclass clazz, jlong memoryAddress, jlong size) {
unsigned char const *memory = (unsigned char const *)(uintptr_t)memoryAddress;
UNUSED_PARAMS(__env, clazz)
return (jint)IsEXRFromMemory(memory, (size_t)size);
}

JNIEXPORT jint JNICALL Java_org_lwjgl_util_tinyexr_TinyEXR_nEXRNumLevels(JNIEnv *__env, jclass clazz, jlong exr_imageAddress) {
EXRImage const *exr_image = (EXRImage const *)(uintptr_t)exr_imageAddress;
UNUSED_PARAMS(__env, clazz)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ public class TinyEXR {
TINYEXR_ERROR_INVALID_HEADER = -9,
TINYEXR_ERROR_UNSUPPORTED_FEATURE = -10,
TINYEXR_ERROR_CANT_WRITE_FILE = -11,
TINYEXR_ERROR_SERIALZATION_FAILED = -12,
TINYEXR_ERROR_LAYER_NOT_FOUND = -13;
TINYEXR_ERROR_SERIALIZATION_FAILED = -12,
TINYEXR_ERROR_LAYER_NOT_FOUND = -13,
TINYEXR_ERROR_DATA_TOO_LARGE = -14;

/** Pixel types. */
public static final int
Expand Down Expand Up @@ -184,6 +185,22 @@ public static int EXRLayers(@NativeType("char const *") CharSequence filename, @
}
}

// --- [ IsEXRFromMemory ] ---

/** Unsafe version of: {@link #IsEXRFromMemory} */
public static native int nIsEXRFromMemory(long memory, long size);

/**
* Checks if given data is a EXR image (by just looking up a header section).
*
* <p>Simple wrapper API for {@link #ParseEXRHeaderFromMemory}.</p>
*
* @return {@link #TINYEXR_SUCCESS SUCCESS} for EXR image, {@link #TINYEXR_ERROR_INVALID_HEADER ERROR_INVALID_HEADER} for others
*/
public static int IsEXRFromMemory(@NativeType("unsigned char const *") ByteBuffer memory) {
return nIsEXRFromMemory(memAddress(memory), memory.remaining());
}

// --- [ EXRNumLevels ] ---

/** Unsafe version of: {@link #EXRNumLevels} */
Expand Down
Loading

0 comments on commit 3bbf3ad

Please sign in to comment.