java-native-interface

Access to raw data in ARGB_8888 Android Bitmap

自古美人都是妖i 提交于 2020-01-09 18:00:59
问题 I am trying to access the raw data of a Bitmap in ARGB_8888 format on Android, using the copyPixelsToBuffer and copyPixelsFromBuffer methods. However, invocation of those calls seems to always apply the alpha channel to the rgb channels. I need the raw data in a byte[] or similar (to pass through JNI; yes, I know about bitmap.h in Android 2.2, cannot use that). Here is a sample: // Create 1x1 Bitmap with alpha channel, 8 bits per channel Bitmap one = Bitmap.createBitmap(1,1,Bitmap.Config.ARGB

How can I read the window title with JNI or JNA?

南楼画角 提交于 2020-01-09 10:46:48
问题 Looking to get back into the development space; primarily using Java to call some native win32 functions (I don't desire to build in .NET).... Can someone point me to a place where I can read the title from a differnt running window using Java (JNI/JNA/SWIG). Assume you would know where in the memory space the application you are attempting to hook into is. 回答1: In JNA: public interface User32 extends StdCallLibrary { User32 INSTANCE = (User32) Native.loadLibrary("user32", User32.class); int

android - javah doesn't find my class

岁酱吖の 提交于 2020-01-09 07:15:07
问题 I am having troubles generating the C header file for JNI using javah . Here's the script I use while standing in the <project-dir>\bin directory: javah -classpath C:\PROGRA~2\Android\android-sdk\platforms\android-8\android.jar com.test.JniTest As return I get: ERROR: Could not find class file for 'com.test.JniTest'. Even though the class JniTest certainly is in \com\test . What am I doing wrong? 回答1: You specify the classpath to contain only android.jar . You also need to include the

How to return 2D long array with JNI

前提是你 提交于 2020-01-07 07:43:09
问题 I'm writing a code which must return a long array from C to java using JNI. But the method (*env)->FindClass returns NULL whatever I tried. Here is my code : // Returns a 2D long array from C to Java JNIEXPORT jobjectArray JNICALL Java_awax_tools_AcquisitionWrapper_startAcquisition (JNIEnv *env, jobject obj) { // (...) Acquisition code // The 2D long array to return long** primitive2DArray = data; // Get the long array class jclass longArrayClass = (*env)->FindClass(env, "[java/lang/Long"); /

Debug Java Code called via JNI

蹲街弑〆低调 提交于 2020-01-07 06:40:07
问题 I have a piece of code where I am creating a Java VM via JNI and then invoking a method on a java .class file. How do i debug the java code via an IDE say eclipse or Netbeans. My c++ project is setup in visual studio and the java project is setup using eclipse. Till now I was using logs to debug the java code. 回答1: You need to use remote debugging see http://java.dzone.com/articles/how-debug-remote-java-applicat 来源: https://stackoverflow.com/questions/5864865/debug-java-code-called-via-jni

Android Webview JNI ERROR with loadUrl

徘徊边缘 提交于 2020-01-07 01:58:07
问题 I'm writing an Android App which is opening a locally stored html file check.html . This html file is showing some nice text and then http-forwarding to my real wanted webpage. Now it can happen, that the server is down, or even the network is unplugged, but I want the app to keep trying to reach it all the time. In case that just the server is down, Android has some latency when asking for the webpage before returning to onReceivedError() , so I don't have a problem, but if the network is

use JNI to start JVM Builder C++

强颜欢笑 提交于 2020-01-06 18:57:06
问题 in this post How to use JNI to start JVM in builder C++ application i converted jvm.lib from Coff to Omf. i used it to link JNI_CreateJavaVM() function. But it crash . I used another code to start JVM from Builder C++ application. When i load the jvm.dll. It work!! the JVM is created when i load jvm in java directory but not when i copy this file(jvm.dll) in another directory and call it from this directory.Can you explain why i can't use a copy of jvm.dll to creat my JVM? This is my Code :

What to use instead of LPTSTR in java JNA?

那年仲夏 提交于 2020-01-06 17:58:06
问题 I am adding User32Ext methods to JNI. In particular, I extended the original UserExt class: package sirius.core; import com.sun.jna.Native; import com.sun.jna.Pointer; import com.sun.jna.platform.win32.Kernel32; import com.sun.jna.platform.win32.WinDef; import com.sun.jna.platform.win32.WinNT; import com.sun.jna.win32.W32APIOptions; public abstract interface Kernel32Ext extends Kernel32 { public static final Kernel32Ext INSTANCE = (Kernel32Ext)Native.loadLibrary("kernel32.dll", Kernel32Ext

Issue with writing FaceRecognizer for Java with OpenCV 2.4.8

痴心易碎 提交于 2020-01-06 10:52:09
问题 I have been given a project based around face recognition written in JavaCV to be improved. The idea was to either rewrite the program using C++ or write JNI bindings to still use Java. I did some research and according to the official website OpenCV as of version 2.4.4 has bindings for Java and Python. And so, since the official website stated so I decided to go with it. Please note I haven't programmed in C++ before nor have I written any JNI wrappers in the past. If the official website

Convert managed unsigned char* into a jbyte*

二次信任 提交于 2020-01-06 08:29:09
问题 How can I convert a managed unsigned char* into a jbyte*? since I'm new to this, a snippet would be helpful too. here is my native code:- JNIEXPORT jobject JNICALL Java_com_me_NativeCaller_processImages (JNIEnv *env, jclass c, jbyteArray front, jbyteArray back){ unsigned char* frontBuffer = convertJByteArrayIntoUnsignedChar(env, front); unsigned char* backBuffer = convertJByteArrayIntoUnsignedChar(env, back); System::Collections::Generic::List<cli::array<unsigned char>^>^ returnedValue =