diff options
author | Sebastian Rasmussen <sebras@gmail.com> | 2017-10-24 15:47:05 +0200 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-11-22 23:09:51 +0100 |
commit | 4dbc82dac40cc8fa4c97a9835e4c4b80a13f5dac (patch) | |
tree | f9988c0347b0c8bfd45fbe99f80a2ed850305232 | |
parent | 0acaaa4065c8cfd919fed46cf703146b9ed7b07a (diff) | |
download | mupdf-4dbc82dac40cc8fa4c97a9835e4c4b80a13f5dac.tar.xz |
jni: Return correct inklist coordinates.
-rw-r--r-- | platform/java/mupdf_native.c | 11 | ||||
-rw-r--r-- | source/pdf/pdf-annot-edit.c | 2 | ||||
-rw-r--r-- | source/tools/murun.c | 5 |
3 files changed, 10 insertions, 8 deletions
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c index ccc50fad..1845f4b9 100644 --- a/platform/java/mupdf_native.c +++ b/platform/java/mupdf_native.c @@ -8447,7 +8447,7 @@ FUN(PDFAnnotation_getInkList)(JNIEnv *env, jobject self) if (!ctx || !annot) return NULL; fz_try(ctx) - n = pdf_annot_quad_point_count(ctx, annot); + n = pdf_annot_ink_list_count(ctx, annot); fz_catch(ctx) { jni_rethrow(env, ctx); @@ -8467,7 +8467,7 @@ FUN(PDFAnnotation_getInkList)(JNIEnv *env, jobject self) return NULL; } - jpath = (*env)->NewFloatArray(env, m); + jpath = (*env)->NewFloatArray(env, m * 2); if (!jpath) return NULL; for (k = 0; k < m; k++) @@ -8480,7 +8480,7 @@ FUN(PDFAnnotation_getInkList)(JNIEnv *env, jobject self) return NULL; } - (*env)->SetFloatArrayRegion(env, jpath, 0, 2, &v[0]); + (*env)->SetFloatArrayRegion(env, jpath, k * 2, 2, &v[0]); if ((*env)->ExceptionCheck(env)) return NULL; } @@ -8545,14 +8545,15 @@ FUN(PDFAnnotation_setInkList)(JNIEnv *env, jobject self, jobject jinklist) if (!jpath) continue; - counts[i] = (*env)->GetArrayLength(env, jpath) / 2; - (*env)->GetFloatArrayRegion(env, jpath, k, counts[i], points); + counts[i] = (*env)->GetArrayLength(env, jpath); + (*env)->GetFloatArrayRegion(env, jpath, 0, counts[i], &points[k]); if ((*env)->ExceptionCheck(env)) { fz_free(ctx, counts); fz_free(ctx, points); return; } + counts[i] /= 2; (*env)->DeleteLocalRef(env, jpath); } diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c index ee3b1964..dbca68c6 100644 --- a/source/pdf/pdf-annot-edit.c +++ b/source/pdf/pdf-annot-edit.c @@ -743,7 +743,7 @@ pdf_annot_ink_list_stroke_count(fz_context *ctx, pdf_annot *annot, int i) check_allowed_subtypes(ctx, annot, PDF_NAME_InkList, ink_list_subtypes); ink_list = pdf_dict_get(ctx, annot->obj, PDF_NAME_InkList); stroke = pdf_array_get(ctx, ink_list, i); - return pdf_array_len(ctx, stroke); + return pdf_array_len(ctx, stroke) / 2; } void diff --git a/source/tools/murun.c b/source/tools/murun.c index 6754b32e..2e407c99 100644 --- a/source/tools/murun.c +++ b/source/tools/murun.c @@ -4158,7 +4158,7 @@ static void ffi_PDFAnnotation_getInkList(js_State *J) fz_catch(ctx) rethrow(J); - for (i = 0; i < n; ++n) { + for (i = 0; i < n; ++i) { fz_try(ctx) m = pdf_annot_ink_list_stroke_count(ctx, annot, i); fz_catch(ctx) @@ -4171,8 +4171,9 @@ static void ffi_PDFAnnotation_getInkList(js_State *J) fz_catch(ctx) rethrow(J); js_pushnumber(J, v[0]); + js_setindex(J, -2, k * 2 + 0); js_pushnumber(J, v[1]); - js_setindex(J, -2, k); + js_setindex(J, -2, k * 2 + 1); } js_setindex(J, -2, i); } |