diff options
-rw-r--r-- | include/mupdf/pdf/annot.h | 4 | ||||
-rw-r--r-- | platform/java/mupdf_native.c | 8 | ||||
-rw-r--r-- | source/pdf/pdf-annot-edit.c | 12 | ||||
-rw-r--r-- | source/tools/murun.c | 14 |
4 files changed, 20 insertions, 18 deletions
diff --git a/include/mupdf/pdf/annot.h b/include/mupdf/pdf/annot.h index 4c3a8b75..13111aab 100644 --- a/include/mupdf/pdf/annot.h +++ b/include/mupdf/pdf/annot.h @@ -175,7 +175,7 @@ void pdf_set_annot_quad_points(fz_context *ctx, pdf_annot *annot, int n, const f void pdf_clear_annot_quad_points(fz_context *ctx, pdf_annot *annot); void pdf_add_annot_quad_point(fz_context *ctx, pdf_annot *annot, fz_rect bbox); -void pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *count, const float *v); +void pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *count, const fz_point *v); void pdf_clear_annot_ink_list(fz_context *ctx, pdf_annot *annot); void pdf_add_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, fz_point stroke[]); @@ -193,10 +193,10 @@ void pdf_set_annot_line(fz_context *ctx, pdf_annot *annot, fz_point a, fz_point int pdf_annot_vertex_count(fz_context *ctx, pdf_annot *annot); fz_point pdf_annot_vertex(fz_context *ctx, pdf_annot *annot, int i); +void pdf_set_annot_vertices(fz_context *ctx, pdf_annot *annot, int n, const fz_point *v); void pdf_clear_annot_vertices(fz_context *ctx, pdf_annot *annot); void pdf_add_annot_vertex(fz_context *ctx, pdf_annot *annot, fz_point p); void pdf_set_annot_vertex(fz_context *ctx, pdf_annot *annot, int i, fz_point p); -void pdf_set_annot_vertices(fz_context *ctx, pdf_annot *annot, int n, const float *v); /* pdf_set_text_annot_position: set the position on page for a text (sticky note) annotation. diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c index 29e87b8b..0cf43dea 100644 --- a/platform/java/mupdf_native.c +++ b/platform/java/mupdf_native.c @@ -9164,7 +9164,7 @@ FUN(PDFAnnotation_setInkList)(JNIEnv *env, jobject self, jobject jinklist) pdf_annot *annot = from_PDFAnnotation(env, self); int i, k, n, m; jfloatArray jpath; - float *points = NULL; + fz_point *points = NULL; int *counts = NULL; if (!ctx || !annot) return; @@ -9187,7 +9187,7 @@ FUN(PDFAnnotation_setInkList)(JNIEnv *env, jobject self, jobject jinklist) fz_try(ctx) { counts = fz_malloc(ctx, n * sizeof(int)); - points = fz_malloc(ctx, m * 2 * sizeof(float)); + points = fz_malloc(ctx, m * sizeof(fz_point)); } fz_catch(ctx) { @@ -9210,7 +9210,7 @@ FUN(PDFAnnotation_setInkList)(JNIEnv *env, jobject self, jobject jinklist) continue; counts[i] = (*env)->GetArrayLength(env, jpath); - (*env)->GetFloatArrayRegion(env, jpath, 0, counts[i], &points[k]); + (*env)->GetFloatArrayRegion(env, jpath, 0, counts[i], (float*)&points[k]); if ((*env)->ExceptionCheck(env)) { fz_free(ctx, counts); @@ -9328,7 +9328,7 @@ FUN(PDFAnnotation_setVertices)(JNIEnv *env, jobject self, jobject jvertices) } fz_try(ctx) - pdf_set_annot_vertices(ctx, annot, n, vertices); + pdf_set_annot_vertices(ctx, annot, n, (fz_point*)vertices); fz_always(ctx) fz_free(ctx, vertices); fz_catch(ctx) diff --git a/source/pdf/pdf-annot-edit.c b/source/pdf/pdf-annot-edit.c index 20cc8edd..15541d45 100644 --- a/source/pdf/pdf-annot-edit.c +++ b/source/pdf/pdf-annot-edit.c @@ -720,7 +720,7 @@ pdf_annot_vertex(fz_context *ctx, pdf_annot *annot, int i) } void -pdf_set_annot_vertices(fz_context *ctx, pdf_annot *annot, int n, const float *v) +pdf_set_annot_vertices(fz_context *ctx, pdf_annot *annot, int n, const fz_point *v) { pdf_document *doc = annot->page->doc; fz_matrix page_ctm, inv_page_ctm; @@ -738,8 +738,7 @@ pdf_set_annot_vertices(fz_context *ctx, pdf_annot *annot, int n, const float *v) vertices = pdf_new_array(ctx, doc, n * 2); for (i = 0; i < n; ++i) { - point.x = v[i * 2]; - point.y = v[i * 2 + 1]; + point = v[i]; fz_transform_point(&point, &inv_page_ctm); pdf_array_push_drop(ctx, vertices, pdf_new_real(ctx, doc, point.x)); pdf_array_push_drop(ctx, vertices, pdf_new_real(ctx, doc, point.y)); @@ -974,7 +973,7 @@ pdf_annot_ink_list_stroke_vertex(fz_context *ctx, pdf_annot *annot, int i, int k } void -pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *count, const float *v) +pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *count, const fz_point *v) { pdf_document *doc = annot->page->doc; fz_matrix page_ctm, inv_page_ctm; @@ -992,11 +991,10 @@ pdf_set_annot_ink_list(fz_context *ctx, pdf_annot *annot, int n, const int *coun ink_list = pdf_new_array(ctx, doc, n); for (i = 0; i < n; ++i) { - stroke = pdf_new_array(ctx, doc, count[i]); + stroke = pdf_new_array(ctx, doc, count[i] * 2); for (k = 0; k < count[i]; ++k) { - point.x = *v++; - point.y = *v++; + point = *v++; fz_transform_point(&point, &inv_page_ctm); pdf_array_push_drop(ctx, stroke, pdf_new_real(ctx, doc, point.x)); pdf_array_push_drop(ctx, stroke, pdf_new_real(ctx, doc, point.y)); diff --git a/source/tools/murun.c b/source/tools/murun.c index fd6c2c0d..bed686a7 100644 --- a/source/tools/murun.c +++ b/source/tools/murun.c @@ -4281,7 +4281,7 @@ static void ffi_PDFAnnotation_setInkList(js_State *J) { fz_context *ctx = js_getcontext(J); pdf_annot *annot = js_touserdata(J, 0, "pdf_annot"); - float *points = NULL; + fz_point *points = NULL; int *counts = NULL; int n, nv, k, i, v; @@ -4298,7 +4298,7 @@ static void ffi_PDFAnnotation_setInkList(js_State *J) fz_try(ctx) { counts = fz_malloc(ctx, n * sizeof(int)); - points = fz_malloc(ctx, nv * 2 * sizeof(float)); + points = fz_malloc(ctx, nv * sizeof(fz_point)); } fz_catch(ctx) { fz_free(ctx, counts); fz_free(ctx, points); @@ -4313,10 +4313,14 @@ static void ffi_PDFAnnotation_setInkList(js_State *J) for (i = v = 0; i < n; ++i) { js_getindex(J, 1, i); counts[i] = js_getlength(J, -1) / 2; - for (k = 0; k < counts[i] * 2; ++k) { - js_getindex(J, -1, k); - points[v++] = js_tonumber(J, -1); + for (k = 0; k < counts[i]; ++k) { + js_getindex(J, -1, k*2); + points[v].x = js_tonumber(J, -1); + js_pop(J, 1); + js_getindex(J, -1, k*2+1); + points[v].y = js_tonumber(J, -1); js_pop(J, 1); + ++v; } js_pop(J, 1); } |