Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. package com.artifex.mupdf;
  2. import android.graphics.*;
  3.  
  4. public class MuPDFCore
  5. {
  6.         /* load our native library */
  7.         static {
  8.                 System.loadLibrary("mupdf");
  9.         }
  10.  
  11.         /* Readable members */
  12.         public int pageNum;
  13.         public int numPages;
  14.         public float pageWidth;
  15.         public float pageHeight;
  16.  
  17.         /* The native functions */
  18.         private static native int openFile(String filename);
  19.         private static native void gotoPageInternal(int localActionPageNum);
  20.         private static native float getPageWidth();
  21.         private static native float getPageHeight();
  22.         public static native void drawPage(Bitmap bitmap,
  23.                         int pageW, int pageH,
  24.                         int patchX, int patchY,
  25.                         int patchW, int patchH);
  26.         public static native void destroying();
  27.  
  28.         public MuPDFCore(String filename) throws Exception
  29.         {
  30.                 numPages = openFile(filename);
  31.                 if (numPages <= 0)
  32.                 {
  33.                         throw new Exception("Failed to open "+filename);
  34.                 }
  35.                 pageNum = 0;
  36.         }
  37.  
  38.         /* Shim function */
  39.         public void gotoPage(int page)
  40.         {
  41.                 if (page > numPages-1)
  42.                         page = numPages-1;
  43.                 else if (page < 0)
  44.                         page = 0;
  45.                 gotoPageInternal(page);
  46.                 this.pageNum = page;
  47.                 this.pageWidth = getPageWidth();
  48.                 this.pageHeight = getPageHeight();
  49.         }
  50.  
  51.         public void onDestroy() {
  52.                 destroying();
  53.         }
  54. }
  55.