Skip to content

Commit

Permalink
add LibRawJniWrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
KillerInk committed Nov 23, 2020
1 parent ce23f96 commit 66d5cb7
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 2 deletions.
53 changes: 53 additions & 0 deletions app/src/main/java/freed/jni/LibRawJniWrapper.java
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());
}
}
2 changes: 1 addition & 1 deletion app/src/main/jni/freedcam/Android.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ LOCAL_ARM_MODE := arm

include $(CLEAR_VARS)
LOCAL_MODULE := libfreedcam
LOCAL_SRC_FILES := RawToDng.cpp librawutils.cpp DngWriter.cpp DngStacker.cpp ExifInfo.cpp GpsInfo.cpp DngProfile.cpp CustomMatrix.cpp OpCode.cpp LibRawWrapper.cpp
LOCAL_SRC_FILES := RawToDng.cpp librawutils.cpp DngWriter.cpp DngStacker.cpp ExifInfo.cpp GpsInfo.cpp DngProfile.cpp CustomMatrix.cpp OpCode.cpp LibRawWrapper.cpp LibRawJniWrapper.cpp
LOCAL_CPPFLAGS := -fexceptions -Wno-c++11-narrowing -frtti -std=c++11 -fpic

LOCAL_LDLIBS := -lz \
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/jni/freedcam/DngProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,4 @@ extern "C"
DngProfile* dngProfile = (DngProfile*)env->GetDirectBufferAddress(javaHandler);
return env->NewStringUTF(dngProfile->bayerformat);
}
};
}
48 changes: 48 additions & 0 deletions app/src/main/jni/freedcam/LibRawJniWrapper.cpp
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);
}
}

0 comments on commit 66d5cb7

Please sign in to comment.