Code Bug Fix: How to read/write Java array from/by C in a fast way

Original Source Link

If possible, I would like to have some confirmation concerning the usage of carrays.i in SWIG.

Based on what I could read so far about carrays.i, it seems that we can read/write a Java array (e.g. int a[] = new int[10]) from/by C only one element at the time. If this conclusion correct? Is there a faster way to read/write a Java array from/by C (i.e. more than one element at the time)?

Tagged : / /

Code Bug Fix: Android Studio | CPP file errors error: undefined reference to ‘AndroidBitmap_unlockPixels’ In bitmap library

Original Source Link

I’m trying to use AndroidJniBitmapOperations library.
But I’m a Junior Dev, with no knowledge in the NDK, JNI world.

I succeed to resolve a few errors like ‘UnsatisfiedLinkError’, but Now I’m getting a new one when I trying to build:

error: undefined reference to ‘AndroidBitmap_unlockPixels’

Also I get a few errors inside the CPP file:

1.”Incorrect type for parameter ‘prarmeterName’, which should have type ‘jint’.

2.”Add extern ‘C'”

But I don’t sure if the last 2 are important.

Help me to update this library, because its important and talked in SO several times, like: here.

The link for the library it self:
https://github.com/AndroidDeveloperLB/AndroidJniBitmapOperations

All what I have done until now is:
https://github.com/LiorA1/MyRevApp

You need to link the library that provides that API. In https://github.com/LiorA1/MyRevApp/blob/master/app/src/main/cpp/CMakeLists.txt, copy the code that you have for the logging library like so:

find_library(log-lib log)
find_library(jnigraphics-lib jnigraphics)
target_link_libraries(JniBitmapOperationsLibrary ${log-lib} ${jnigraphics-lib})

Although I think the template code is actually overly complicated here and you can simplify to just:

target_link_libraries(JniBitmapOperationsLibrary -llog -ljnigraphics)

Untested though.

As for how you can figure out which library you need to use for each Android API, I find the easiest way is to search for it on cs.android.com. For this one, I searched for AndroidBitmap_unlockPixels file:.*.map.txt (every NDK API is enumerated in a *.map.txt file). You can also use this page, but the code search is authoritative and makes it easier to look up an individual function rather than just “bitmap”, in this case.

Tagged : / / /