-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
103 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package freed.jni; | ||
|
||
import android.graphics.Bitmap; | ||
|
||
import java.nio.ByteBuffer; | ||
|
||
|
||
public class LibRawJniWrapper | ||
{ | ||
private ByteBuffer byteBuffer; | ||
|
||
static | ||
{ | ||
System.loadLibrary("freedcam"); | ||
} | ||
|
||
private native ByteBuffer init(); | ||
private native void openFile(ByteBuffer byteBuffer, String filename); | ||
private native void openFD(ByteBuffer byteBuffer, int fd); | ||
private native Bitmap getBitmap(ByteBuffer byteBuffer); | ||
private native void release(ByteBuffer byteBuffer); | ||
private native void getExifInfo(ByteBuffer byteBuffer, ByteBuffer exifInfo); | ||
|
||
public LibRawJniWrapper() | ||
{ | ||
byteBuffer = init(); | ||
} | ||
|
||
public void openFile(String filepath) | ||
{ | ||
openFile(byteBuffer,filepath); | ||
} | ||
|
||
public void openFile(int filedecriptor) | ||
{ | ||
openFD(byteBuffer,filedecriptor); | ||
} | ||
|
||
public Bitmap getBitmap() | ||
{ | ||
return getBitmap(byteBuffer); | ||
} | ||
|
||
public void release() | ||
{ | ||
release(byteBuffer); | ||
} | ||
|
||
public void getExifInfo(ExifInfo exifInfo) | ||
{ | ||
getExifInfo(byteBuffer,exifInfo.getByteBuffer()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// | ||
// Created by troop on 23.11.2020. | ||
// | ||
#include <jni.h> | ||
#include "LibRawWrapper.h" | ||
|
||
extern "C" | ||
{ | ||
JNIEXPORT jobject JNICALL Java_freed_jni_LibRawJniWrapper_init(JNIEnv *env, jobject thiz) | ||
{ | ||
LibRawWrapper *writer = new LibRawWrapper(); | ||
return env->NewDirectByteBuffer(writer, 0); | ||
} | ||
|
||
JNIEXPORT void JNICALL Java_freed_jni_LibRawJniWrapper_openFile(JNIEnv *env, jobject thiz, jobject byte_buffer, jstring filename) | ||
{ | ||
LibRawWrapper* writer = (LibRawWrapper*)env->GetDirectBufferAddress(byte_buffer); | ||
jboolean bIsCopy; | ||
const char *strFilename = (env)->GetStringUTFChars(filename, &bIsCopy); | ||
writer->openFile(strFilename); | ||
(env)->ReleaseStringUTFChars(filename, strFilename); | ||
} | ||
|
||
JNIEXPORT void JNICALL Java_freed_jni_LibRawJniWrapper_openFD(JNIEnv *env, jobject thiz, jobject byte_buffer, jint fd) | ||
{ | ||
LibRawWrapper* writer = (LibRawWrapper*)env->GetDirectBufferAddress(byte_buffer); | ||
writer->openFD(fd); | ||
} | ||
|
||
JNIEXPORT jobject JNICALL Java_freed_jni_LibRawJniWrapper_getBitmap(JNIEnv *env, jobject thiz, jobject byte_buffer) | ||
{ | ||
LibRawWrapper* writer = (LibRawWrapper*)env->GetDirectBufferAddress(byte_buffer); | ||
return writer->getBitmap(env); | ||
} | ||
|
||
JNIEXPORT void JNICALL Java_freed_jni_LibRawJniWrapper_release(JNIEnv *env, jobject thiz, jobject byte_buffer) { | ||
LibRawWrapper* writer = (LibRawWrapper*)env->GetDirectBufferAddress(byte_buffer); | ||
writer->recycle(); | ||
delete writer; | ||
} | ||
|
||
JNIEXPORT void JNICALL Java_freed_jni_LibRawJniWrapper_getExifInfo(JNIEnv *env, jobject thiz, jobject byte_buffer, jobject exif_info) | ||
{ | ||
LibRawWrapper* writer = (LibRawWrapper*)env->GetDirectBufferAddress(byte_buffer); | ||
ExifInfo * exifInfo = (ExifInfo*)env->GetDirectBufferAddress(exif_info); | ||
writer->getExifInfo(exifInfo); | ||
} | ||
} |