summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2016-06-23 12:33:30 +0200
committerRobin Watts <robin.watts@artifex.com>2016-06-23 16:10:29 +0100
commitcf7b2cbbfe6192fbf697237735ab45bc951304e4 (patch)
treeeac1231a33e79e7f8afa99d63e203b8fededecc4 /platform
parent38ffc7fefeadb87929c2006d1e91394a516c3c9d (diff)
downloadmupdf-cf7b2cbbfe6192fbf697237735ab45bc951304e4.tar.xz
Update JNI code. Take explicit alpha argument in toPixmap functions.
Diffstat (limited to 'platform')
-rw-r--r--platform/gl/gl-main.c4
-rw-r--r--platform/java/com/artifex/mupdf/fitz/Page.java2
-rw-r--r--platform/java/example/PageCanvas.java2
-rw-r--r--platform/java/mupdf_native.c10
-rw-r--r--platform/java/mupdf_native.h8
5 files changed, 13 insertions, 13 deletions
diff --git a/platform/gl/gl-main.c b/platform/gl/gl-main.c
index ff080d1b..e6a93680 100644
--- a/platform/gl/gl-main.c
+++ b/platform/gl/gl-main.c
@@ -263,14 +263,14 @@ void render_page(void)
links = NULL;
links = fz_load_links(ctx, page);
- pix = fz_new_pixmap_from_page_contents(ctx, page, &page_ctm, fz_device_rgb(ctx));
+ pix = fz_new_pixmap_from_page_contents(ctx, page, &page_ctm, fz_device_rgb(ctx), 0);
texture_from_pixmap(&page_tex, pix);
fz_drop_pixmap(ctx, pix);
annot_count = 0;
for (annot = fz_first_annot(ctx, page); annot; annot = fz_next_annot(ctx, annot))
{
- pix = fz_new_pixmap_from_annot(ctx, annot, &page_ctm, fz_device_rgb(ctx));
+ pix = fz_new_pixmap_from_annot(ctx, annot, &page_ctm, fz_device_rgb(ctx), 1);
texture_from_pixmap(&annot_tex[annot_count++], pix);
fz_drop_pixmap(ctx, pix);
}
diff --git a/platform/java/com/artifex/mupdf/fitz/Page.java b/platform/java/com/artifex/mupdf/fitz/Page.java
index befbe1c7..44abc572 100644
--- a/platform/java/com/artifex/mupdf/fitz/Page.java
+++ b/platform/java/com/artifex/mupdf/fitz/Page.java
@@ -20,7 +20,7 @@ public class Page
public native Rect getBounds();
- public native Pixmap toPixmap(Matrix ctm, ColorSpace colorspace);
+ public native Pixmap toPixmap(Matrix ctm, ColorSpace colorspace, boolean alpha);
public native void run(Device dev, Matrix ctm, Cookie cookie);
public native void runPageContents(Device dev, Matrix ctm, Cookie cookie);
diff --git a/platform/java/example/PageCanvas.java b/platform/java/example/PageCanvas.java
index 9de1abdb..11ed1877 100644
--- a/platform/java/example/PageCanvas.java
+++ b/platform/java/example/PageCanvas.java
@@ -30,7 +30,7 @@ public class PageCanvas extends java.awt.Canvas
}
public static BufferedImage imageFromPage(Page page, Matrix ctm) {
- Pixmap pixmap = page.toPixmap(ctm, ColorSpace.DeviceBGR);
+ Pixmap pixmap = page.toPixmap(ctm, ColorSpace.DeviceBGR, true);
BufferedImage image = imageFromPixmap(pixmap);
pixmap.destroy();
return image;
diff --git a/platform/java/mupdf_native.c b/platform/java/mupdf_native.c
index 0528a2fb..7530b041 100644
--- a/platform/java/mupdf_native.c
+++ b/platform/java/mupdf_native.c
@@ -2464,13 +2464,13 @@ FUN(Pixmap_getPixels)(JNIEnv *env, jobject self)
if (ctx == NULL || pixmap == NULL)
return NULL;
- if (pixmap->n != 4)
+ if (pixmap->n != 4 || !pixmap->alpha)
{
- jni_throw(env, FZ_ERROR_GENERIC, "invalid colorspace for getPixels");
+ jni_throw(env, FZ_ERROR_GENERIC, "invalid colorspace for getPixels (must be RGB/BGR with alpha)");
return NULL;
}
- if (size != pixmap->h * pixmap->stride)
+ if (size * 4 != pixmap->h * pixmap->stride)
{
jni_throw(env, FZ_ERROR_GENERIC, "invalid stride for getPixels");
return NULL;
@@ -3461,7 +3461,7 @@ FUN(Page_finalize)(JNIEnv *env, jobject self)
}
JNIEXPORT jobject JNICALL
-FUN(Page_toPixmap)(JNIEnv *env, jobject self, jobject ctm_, jobject colorspace_)
+FUN(Page_toPixmap)(JNIEnv *env, jobject self, jobject ctm_, jobject colorspace_, jboolean alpha)
{
fz_context *ctx = get_context(env);
fz_page *page = from_Page(env, self);
@@ -3471,7 +3471,7 @@ FUN(Page_toPixmap)(JNIEnv *env, jobject self, jobject ctm_, jobject colorspace_)
fz_pixmap *pixmap = NULL;
fz_try(ctx)
- pixmap = fz_new_pixmap_from_page(ctx, page, &ctm, colorspace);
+ pixmap = fz_new_pixmap_from_page(ctx, page, &ctm, colorspace, alpha);
fz_catch(ctx)
jni_rethrow(env, ctx);
diff --git a/platform/java/mupdf_native.h b/platform/java/mupdf_native.h
index a15501d2..08d389a1 100644
--- a/platform/java/mupdf_native.h
+++ b/platform/java/mupdf_native.h
@@ -1055,10 +1055,10 @@ JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_Page_getBounds
/*
* Class: com_artifex_mupdf_fitz_Page
* Method: toPixmap
- * Signature: (Lcom/artifex/mupdf/fitz/Matrix;Lcom/artifex/mupdf/fitz/ColorSpace;)Lcom/artifex/mupdf/fitz/Pixmap;
+ * Signature: (Lcom/artifex/mupdf/fitz/Matrix;Lcom/artifex/mupdf/fitz/ColorSpace;Z)Lcom/artifex/mupdf/fitz/Pixmap;
*/
JNIEXPORT jobject JNICALL Java_com_artifex_mupdf_fitz_Page_toPixmap
- (JNIEnv *, jobject, jobject, jobject);
+ (JNIEnv *, jobject, jobject, jobject, jboolean);
/*
* Class: com_artifex_mupdf_fitz_Page
@@ -1264,10 +1264,10 @@ JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Pixmap_clearWithValue
/*
* Class: com_artifex_mupdf_fitz_Pixmap
* Method: saveAsPNG
- * Signature: (Ljava/lang/String;Z)V
+ * Signature: (Ljava/lang/String;)V
*/
JNIEXPORT void JNICALL Java_com_artifex_mupdf_fitz_Pixmap_saveAsPNG
- (JNIEnv *, jobject, jstring, jboolean);
+ (JNIEnv *, jobject, jstring);
/*
* Class: com_artifex_mupdf_fitz_Pixmap