boxa.cpp 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright 2011, Google Inc.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #include "common.h"
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif /* __cplusplus */
  20. void Java_com_googlecode_leptonica_android_Boxa_nativeDestroy(JNIEnv *env, jclass clazz, jlong nativeBoxa) {
  21. BOXA *boxa = (BOXA *) nativeBoxa;
  22. boxaDestroy(&boxa);
  23. }
  24. jboolean Java_com_googlecode_leptonica_android_Boxa_nativeGetGeometry(JNIEnv *env, jclass clazz,
  25. jlong nativeBoxa,
  26. jint index,
  27. jintArray dimensions) {
  28. BOXA *boxa = (BOXA *) nativeBoxa;
  29. jint *dimensionArray = env->GetIntArrayElements(dimensions, NULL);
  30. l_int32 x, y, w, h;
  31. if (boxaGetBoxGeometry(boxa,index, &x, &y, &w, &h)) {
  32. return JNI_FALSE;
  33. }
  34. dimensionArray[0] = x;
  35. dimensionArray[1] = y;
  36. dimensionArray[2] = w;
  37. dimensionArray[3] = h;
  38. env->ReleaseIntArrayElements(dimensions, dimensionArray, 0);
  39. return JNI_TRUE;
  40. }
  41. #ifdef __cplusplus
  42. }
  43. #endif /* __cplusplus */