Visual Servoing Platform version 3.6.0
Loading...
Searching...
No Matches
VpImageUChar.cpp
1#include <cstring>
2#include <sstream>
3#include <visp3/core/vpImage.h>
4typedef unsigned char u_char;
5
6extern "C" {
7
8#if !defined(__ppc__)
9// to suppress warning from jni.h on OS X
10#define TARGET_RT_MAC_CFM 0
11#endif
12#include <jni.h>
13
14// Java Method: VpImageUChar()
15JNIEXPORT jlong JNICALL Java_org_visp_core_VpImageUChar_n_1VpImageUChar__(JNIEnv *env, jclass, jstring type)
16{
17 (void)env;
18 (void)type;
19 return (jlong) new vpImage<u_char>();
20}
21
22// Java Method: VpImageUChar(int r, int c)
23JNIEXPORT jlong JNICALL Java_org_visp_core_VpImageUChar_n_1VpImageUChar__II(JNIEnv *env, jclass, jint r, jint c)
24{
25 (void)env;
26 return (jlong) new vpImage<u_char>(r, c);
27}
28
29// Java Method: VpImageUChar(int r, int c, byte val)
30JNIEXPORT jlong JNICALL Java_org_visp_core_VpImageUChar_n_1VpImageUChar__IIB(JNIEnv *env, jclass, jint r, jint c,
31 jbyte value)
32{
33 (void)env;
34 return (jlong) new vpImage<u_char>(r, c, (u_char)value);
35}
36
37// Java Method: VpImageUChar(byte[] array, int height, int width, boolean copyData)
38JNIEXPORT jlong JNICALL Java_org_visp_core_VpImageUChar_n_1VpImageUChar___3BIIZ(JNIEnv *env, jclass, jbyteArray arr,
39 jint h, jint w, jboolean copyData)
40{
41 jbyte *array = env->GetByteArrayElements(arr, NULL);
42
43 return (jlong) new vpImage<u_char>((u_char *const)array, (const unsigned int)h, (const unsigned int)w, copyData);
44
45 // be memory friendly
46 env->ReleaseByteArrayElements(arr, array, 0);
47}
48
49// Java Method: getCols()
50JNIEXPORT jint JNICALL Java_org_visp_core_VpImageUChar_n_1cols(JNIEnv *env, jclass, jlong address)
51{
52 (void)env;
53 vpImage<u_char> *me = (vpImage<u_char> *)address; // TODO: check for NULL
54 return me->getCols();
55}
56
57// Java Method: getRows()
58JNIEXPORT jint JNICALL Java_org_visp_core_VpImageUChar_n_1rows(JNIEnv *env, jclass, jlong address)
59{
60 (void)env;
61 vpImage<u_char> *me = (vpImage<u_char> *)address; // TODO: check for NULL
62 return me->getRows();
63}
64
65// Java Method: getPixel(int i, int j)
66JNIEXPORT jint JNICALL Java_org_visp_core_VpImageUChar_n_1getPixel(JNIEnv *env, jclass, jlong address, jint i, jint j)
67{
68 (void)env;
69 vpImage<u_char> *me = (vpImage<u_char> *)address; // TODO: check for NULL
70 return (*me)(i, j);
71}
72
73// Java Method: getPixels()
74JNIEXPORT jbyteArray JNICALL Java_org_visp_core_VpImageUChar_n_1getPixels(JNIEnv *env, jclass, jlong address)
75{
76 vpImage<u_char> *me = (vpImage<u_char> *)address; // TODO: check for NULL
77 jbyteArray ret = env->NewByteArray(me->getNumberOfPixel());
78 env->SetByteArrayRegion(ret, 0, me->getNumberOfPixel(), (jbyte *)me->bitmap);
79 return ret;
80}
81
82// Java Method: dump()
83JNIEXPORT jstring JNICALL Java_org_visp_core_VpImageUChar_n_1dump(JNIEnv *env, jclass, jlong address)
84{
85 vpImage<u_char> *me = (vpImage<u_char> *)address; // TODO: check for NULL
86 std::stringstream ss;
87 ss << *me;
88 return env->NewStringUTF(ss.str().c_str());
89}
90
91} // extern "C"
Definition of the vpImage class member functions.
Definition vpImage.h:135
unsigned int getNumberOfPixel() const
Definition vpImage.h:205
unsigned int getCols() const
Definition vpImage.h:175
Type * bitmap
points toward the bitmap
Definition vpImage.h:139
unsigned int getRows() const
Definition vpImage.h:214