summaryrefslogtreecommitdiff
path: root/android
diff options
context:
space:
mode:
authorTor Andersson <tor@ghostscript.com>2011-02-05 07:54:38 +0000
committerTor Andersson <tor@ghostscript.com>2011-02-05 07:54:38 +0000
commit1cd8d2d359ff0c8ea7ba7a5837bc4a4f2f4e02ad (patch)
tree67d2b5ad3e9c5af48be9703da9ad585e010f3eb9 /android
parent05f498d5ef0b54bc6062e3993049e746a54e2bad (diff)
downloadmupdf-1cd8d2d359ff0c8ea7ba7a5837bc4a4f2f4e02ad.tar.xz
Add missing MuPDFCore.java file.
Diffstat (limited to 'android')
-rw-r--r--android/src/com/artifex/mupdf/MuPDFCore.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/android/src/com/artifex/mupdf/MuPDFCore.java b/android/src/com/artifex/mupdf/MuPDFCore.java
new file mode 100644
index 00000000..245ffdc0
--- /dev/null
+++ b/android/src/com/artifex/mupdf/MuPDFCore.java
@@ -0,0 +1,52 @@
+package com.artifex.mupdf;
+import android.graphics.*;
+
+public class MuPDFCore
+{
+ /* load our native library */
+ static {
+ System.loadLibrary("mupdf");
+ }
+
+ /* Readable members */
+ public int pageNum;
+ public int numPages;
+ public float pageWidth;
+ public float pageHeight;
+
+ /* The native functions */
+ private static native int openFile(String filename);
+ private static native void gotoPageInternal(int localActionPageNum);
+ private static native float getPageWidth();
+ private static native float getPageHeight();
+ public static native void drawPage(Bitmap bitmap,
+ int pageW,
+ int pageH,
+ int patchX,
+ int patchY,
+ int patchW,
+ int patchH);
+
+ public MuPDFCore(String filename) throws Exception
+ {
+ numPages = openFile(filename);
+ if (numPages <= 0)
+ {
+ throw new Exception("Failed to open "+filename);
+ }
+ pageNum = 1;
+ }
+
+ /* Shim function */
+ public void gotoPage(int page)
+ {
+ if (page > numPages)
+ page = numPages;
+ else if (page < 1)
+ page = 1;
+ gotoPageInternal(page);
+ this.pageNum = page;
+ this.pageWidth = getPageWidth();
+ this.pageHeight = getPageHeight();
+ }
+}