diff options
Diffstat (limited to 'platform')
-rw-r--r-- | platform/android/viewer/jni/mupdf.c | 47 | ||||
-rw-r--r-- | platform/ios/Classes/MuPageViewNormal.m | 36 |
2 files changed, 46 insertions, 37 deletions
diff --git a/platform/android/viewer/jni/mupdf.c b/platform/android/viewer/jni/mupdf.c index 96dc36df..9f26651b 100644 --- a/platform/android/viewer/jni/mupdf.c +++ b/platform/android/viewer/jni/mupdf.c @@ -1541,7 +1541,7 @@ JNI_FN(MuPDFCore_addMarkupAnnotationInternal)(JNIEnv * env, jobject thiz, jobjec jclass pt_cls; jfieldID x_fid, y_fid; int i, n; - fz_point *pts = NULL; + float *pts = NULL; float color[3]; float alpha; float line_height; @@ -1598,19 +1598,22 @@ JNI_FN(MuPDFCore_addMarkupAnnotationInternal)(JNIEnv * env, jobject thiz, jobjec n = (*env)->GetArrayLength(env, points); - pts = fz_malloc_array(ctx, n, sizeof(fz_point)); + pts = fz_malloc_array(ctx, n * 2, sizeof(float)); for (i = 0; i < n; i++) { + fz_point pt; jobject opt = (*env)->GetObjectArrayElement(env, points, i); - pts[i].x = opt ? (*env)->GetFloatField(env, opt, x_fid) : 0.0f; - pts[i].y = opt ? (*env)->GetFloatField(env, opt, y_fid) : 0.0f; - fz_transform_point(&pts[i], &ctm); + pt.x = opt ? (*env)->GetFloatField(env, opt, x_fid) : 0.0f; + pt.y = opt ? (*env)->GetFloatField(env, opt, y_fid) : 0.0f; + fz_transform_point(&pt, &ctm); + pts[i*2+0] = pt.x; + pts[i*2+1] = pt.y; } - annot = (fz_annot *)pdf_create_annot(ctx, idoc, (pdf_page *)pc->page, type); + annot = (fz_annot *)pdf_create_annot(ctx, (pdf_page *)pc->page, type); - pdf_set_markup_annot_quadpoints(ctx, idoc, (pdf_annot *)annot, pts, n); + pdf_set_annot_quad_points(ctx, (pdf_annot *)annot, n / 4, pts); pdf_set_markup_appearance(ctx, idoc, (pdf_annot *)annot, color, alpha, line_thickness, line_height); dump_annotation_display_lists(glo); @@ -1640,10 +1643,10 @@ JNI_FN(MuPDFCore_addInkAnnotationInternal)(JNIEnv * env, jobject thiz, jobjectAr jclass pt_cls; jfieldID x_fid, y_fid; int i, j, k, n; - fz_point *pts = NULL; + float *pts = NULL; int *counts = NULL; int total = 0; - float color[3]; + float color[4]; if (idoc == NULL) return; @@ -1651,12 +1654,13 @@ JNI_FN(MuPDFCore_addInkAnnotationInternal)(JNIEnv * env, jobject thiz, jobjectAr color[0] = 1.0; color[1] = 0.0; color[2] = 0.0; + color[3] = 0.0; fz_var(pts); fz_var(counts); fz_try(ctx) { - fz_annot *annot; + pdf_annot *annot; fz_matrix ctm; float zoom = glo->resolution / 72; @@ -1682,7 +1686,7 @@ JNI_FN(MuPDFCore_addInkAnnotationInternal)(JNIEnv * env, jobject thiz, jobjectAr total += count; } - pts = fz_malloc_array(ctx, total, sizeof(fz_point)); + pts = fz_malloc_array(ctx, total * 2, sizeof(float)); k = 0; for (i = 0; i < n; i++) @@ -1692,20 +1696,23 @@ JNI_FN(MuPDFCore_addInkAnnotationInternal)(JNIEnv * env, jobject thiz, jobjectAr for (j = 0; j < count; j++) { - jobject pt = (*env)->GetObjectArrayElement(env, arc, j); - - pts[k].x = pt ? (*env)->GetFloatField(env, pt, x_fid) : 0.0f; - pts[k].y = pt ? (*env)->GetFloatField(env, pt, y_fid) : 0.0f; - (*env)->DeleteLocalRef(env, pt); - fz_transform_point(&pts[k], &ctm); - k++; + jobject jpt = (*env)->GetObjectArrayElement(env, arc, j); + fz_point pt; + pt.x = jpt ? (*env)->GetFloatField(env, jpt, x_fid) : 0.0f; + pt.y = jpt ? (*env)->GetFloatField(env, jpt, y_fid) : 0.0f; + (*env)->DeleteLocalRef(env, jpt); + fz_transform_point(&pt, &ctm); + pts[k++] = pt.x; + pts[k++] = pt.y; } (*env)->DeleteLocalRef(env, arc); } - annot = (fz_annot *)pdf_create_annot(ctx, idoc, (pdf_page *)pc->page, PDF_ANNOT_INK); + annot = pdf_create_annot(ctx, (pdf_page *)pc->page, PDF_ANNOT_INK); - pdf_set_ink_annot_list(ctx, idoc, (pdf_annot *)annot, pts, counts, n, color, INK_THICKNESS); + pdf_set_annot_border(ctx, annot, INK_THICKNESS); + pdf_set_annot_color(ctx, annot, 3, color); + pdf_set_annot_ink_list(ctx, annot, n, counts, pts); dump_annotation_display_lists(glo); } diff --git a/platform/ios/Classes/MuPageViewNormal.m b/platform/ios/Classes/MuPageViewNormal.m index f5afdcee..08f38786 100644 --- a/platform/ios/Classes/MuPageViewNormal.m +++ b/platform/ios/Classes/MuPageViewNormal.m @@ -203,7 +203,7 @@ static void addMarkupAnnot(fz_document *doc, fz_page *page, int type, NSArray *r int i; pdf_annot *annot; - quadpts = fz_malloc_array(ctx, (int)rects.count * 4, sizeof(fz_point)); + quadpts = fz_malloc_array(ctx, (int)rects.count * 8, sizeof(float)); for (i = 0; i < rects.count; i++) { CGRect rect = [rects[i] CGRectValue]; @@ -211,18 +211,18 @@ static void addMarkupAnnot(fz_document *doc, fz_page *page, int type, NSArray *r float bot = top + rect.size.height; float left = rect.origin.x; float right = left + rect.size.width; - quadpts[i*4].x = left; - quadpts[i*4].y = bot; - quadpts[i*4+1].x = right; - quadpts[i*4+1].y = bot; - quadpts[i*4+2].x = right; - quadpts[i*4+2].y = top; - quadpts[i*4+3].x = left; - quadpts[i*4+3].y = top; + quadpts[i*8+0] = left; + quadpts[i*8+1] = bot; + quadpts[i*8+2] = right; + quadpts[i*8+3] = bot; + quadpts[i*8+4] = right; + quadpts[i*8+5] = top; + quadpts[i*8+6] = left; + quadpts[i*8+7] = top; } annot = pdf_create_annot(ctx, idoc, (pdf_page *)page, type); - pdf_set_markup_annot_quadpoints(ctx, idoc, annot, quadpts, (int)rects.count*4); + pdf_set_annot_quad_points(ctx, idoc, annot, rects.count, quadpts); pdf_set_markup_appearance(ctx, idoc, annot, color, alpha, line_thickness, line_height); } fz_always(ctx) @@ -238,10 +238,10 @@ static void addMarkupAnnot(fz_document *doc, fz_page *page, int type, NSArray *r static void addInkAnnot(fz_document *doc, fz_page *page, NSArray *curves) { pdf_document *idoc; - fz_point *pts = NULL; + float *pts = NULL; int *counts = NULL; int total; - float color[3] = {1.0, 0.0, 0.0}; + float color[4] = {1.0, 0.0, 0.0, 0.0}; idoc = pdf_specifics(ctx, doc); if (!idoc) @@ -266,7 +266,7 @@ static void addInkAnnot(fz_document *doc, fz_page *page, NSArray *curves) total += (int)curve.count; } - pts = fz_malloc_array(ctx, total, sizeof(fz_point)); + pts = fz_malloc_array(ctx, total * 2, sizeof(float)); k = 0; for (i = 0; i < n; i++) @@ -277,14 +277,16 @@ static void addInkAnnot(fz_document *doc, fz_page *page, NSArray *curves) for (j = 0; j < count; j++) { CGPoint pt = [curve[j] CGPointValue]; - pts[k].x = pt.x; - pts[k].y = pt.y; - k++; + pts[k++] = pt.x; + pts[k++] = pt.y; } } annot = pdf_create_annot(ctx, idoc, (pdf_page *)page, PDF_ANNOT_INK); - pdf_set_ink_annot_list(ctx, idoc, annot, pts, counts, n, color, INK_THICKNESS); + + pdf_set_annot_border(ctx, annot, INK_THICKNESS); + pdf_set_annot_color(ctx, annot, 3, color); + pdf_set_annot_ink_list(ctx, annot, ncount, counts, pts); } fz_always(ctx) { |