Subversion Repositories Kolibri OS

Compare Revisions

Regard whitespace Rev 4679 → Rev 4680

/contrib/media/updf/android/jni/Android.mk
0,0 → 1,22
LOCAL_PATH := $(call my-dir)
TOP_LOCAL_PATH := $(LOCAL_PATH)
 
MUPDF_ROOT := ..
 
include $(TOP_LOCAL_PATH)/Core.mk
include $(TOP_LOCAL_PATH)/ThirdParty.mk
 
include $(CLEAR_VARS)
 
LOCAL_C_INCLUDES := \
$(MUPDF_ROOT)/draw \
$(MUPDF_ROOT)/fitz \
$(MUPDF_ROOT)/pdf
LOCAL_CFLAGS :=
LOCAL_MODULE := mupdf
LOCAL_SRC_FILES := mupdf.c
LOCAL_STATIC_LIBRARIES := mupdfcore mupdfthirdparty
 
LOCAL_LDLIBS := -lm -llog -ljnigraphics
 
include $(BUILD_SHARED_LIBRARY)
/contrib/media/updf/android/jni/Application.mk
0,0 → 1,3
# The ARMv7 is significanly faster due to the use of the hardware FPU
APP_ABI := armeabi armeabi-v7a
APP_OPTIM := debug
/contrib/media/updf/android/jni/Core.mk
0,0 → 1,99
LOCAL_PATH := $(call my-dir)
 
include $(CLEAR_VARS)
 
MY_ROOT := ../..
 
LOCAL_C_INCLUDES := \
../thirdparty/jbig2dec \
../thirdparty/openjpeg-1.4/libopenjpeg \
../thirdparty/jpeg-8c \
../thirdparty/zlib-1.2.5 \
../thirdparty/freetype-2.4.4/include \
../draw \
../fitz \
../pdf \
../scripts \
..
 
LOCAL_MODULE := mupdfcore
LOCAL_SRC_FILES := \
$(MY_ROOT)/fitz/base_error.c \
$(MY_ROOT)/fitz/base_geometry.c \
$(MY_ROOT)/fitz/base_getopt.c \
$(MY_ROOT)/fitz/base_hash.c \
$(MY_ROOT)/fitz/base_memory.c \
$(MY_ROOT)/fitz/base_object.c \
$(MY_ROOT)/fitz/base_string.c \
$(MY_ROOT)/fitz/base_time.c \
$(MY_ROOT)/fitz/crypt_aes.c \
$(MY_ROOT)/fitz/crypt_arc4.c \
$(MY_ROOT)/fitz/crypt_md5.c \
$(MY_ROOT)/fitz/crypt_sha2.c \
$(MY_ROOT)/fitz/dev_bbox.c \
$(MY_ROOT)/fitz/dev_list.c \
$(MY_ROOT)/fitz/dev_null.c \
$(MY_ROOT)/fitz/dev_text.c \
$(MY_ROOT)/fitz/dev_trace.c \
$(MY_ROOT)/fitz/filt_basic.c \
$(MY_ROOT)/fitz/filt_dctd.c \
$(MY_ROOT)/fitz/filt_faxd.c \
$(MY_ROOT)/fitz/filt_flate.c \
$(MY_ROOT)/fitz/filt_jbig2d.c \
$(MY_ROOT)/fitz/filt_jpxd.c \
$(MY_ROOT)/fitz/filt_lzwd.c \
$(MY_ROOT)/fitz/filt_predict.c \
$(MY_ROOT)/fitz/obj_print.c \
$(MY_ROOT)/fitz/res_colorspace.c \
$(MY_ROOT)/fitz/res_font.c \
$(MY_ROOT)/fitz/res_path.c \
$(MY_ROOT)/fitz/res_pixmap.c \
$(MY_ROOT)/fitz/res_shade.c \
$(MY_ROOT)/fitz/res_text.c \
$(MY_ROOT)/fitz/stm_buffer.c \
$(MY_ROOT)/fitz/stm_open.c \
$(MY_ROOT)/fitz/stm_read.c \
$(MY_ROOT)/draw/arch_arm.c \
$(MY_ROOT)/draw/arch_port.c \
$(MY_ROOT)/draw/draw_affine.c \
$(MY_ROOT)/draw/draw_blend.c \
$(MY_ROOT)/draw/draw_device.c \
$(MY_ROOT)/draw/draw_edge.c \
$(MY_ROOT)/draw/draw_glyph.c \
$(MY_ROOT)/draw/draw_mesh.c \
$(MY_ROOT)/draw/draw_paint.c \
$(MY_ROOT)/draw/draw_path.c \
$(MY_ROOT)/draw/draw_scale.c \
$(MY_ROOT)/draw/draw_unpack.c \
$(MY_ROOT)/pdf/pdf_annot.c \
$(MY_ROOT)/pdf/pdf_cmap.c \
$(MY_ROOT)/pdf/pdf_cmap_load.c \
$(MY_ROOT)/pdf/pdf_cmap_parse.c \
$(MY_ROOT)/pdf/pdf_cmap_table.c \
$(MY_ROOT)/pdf/pdf_colorspace.c \
$(MY_ROOT)/pdf/pdf_crypt.c \
$(MY_ROOT)/pdf/pdf_encoding.c \
$(MY_ROOT)/pdf/pdf_font.c \
$(MY_ROOT)/pdf/pdf_fontfile.c \
$(MY_ROOT)/pdf/pdf_function.c \
$(MY_ROOT)/pdf/pdf_image.c \
$(MY_ROOT)/pdf/pdf_interpret.c \
$(MY_ROOT)/pdf/pdf_lex.c \
$(MY_ROOT)/pdf/pdf_metrics.c \
$(MY_ROOT)/pdf/pdf_nametree.c \
$(MY_ROOT)/pdf/pdf_outline.c \
$(MY_ROOT)/pdf/pdf_page.c \
$(MY_ROOT)/pdf/pdf_parse.c \
$(MY_ROOT)/pdf/pdf_pattern.c \
$(MY_ROOT)/pdf/pdf_repair.c \
$(MY_ROOT)/pdf/pdf_shade.c \
$(MY_ROOT)/pdf/pdf_store.c \
$(MY_ROOT)/pdf/pdf_stream.c \
$(MY_ROOT)/pdf/pdf_type3.c \
$(MY_ROOT)/pdf/pdf_unicode.c \
$(MY_ROOT)/pdf/pdf_xobject.c \
$(MY_ROOT)/pdf/pdf_xref.c
 
LOCAL_LDLIBS := -lm -llog -ljnigraphics
 
include $(BUILD_STATIC_LIBRARY)
/contrib/media/updf/android/jni/ThirdParty.mk
0,0 → 1,153
LOCAL_PATH := $(call my-dir)
 
include $(CLEAR_VARS)
 
MY_ROOT := ../..
 
LOCAL_C_INCLUDES := \
../thirdparty/jbig2dec \
../thirdparty/openjpeg-1.4/libopenjpeg \
../thirdparty/jpeg-8c \
../thirdparty/zlib-1.2.5 \
../thirdparty/freetype-2.4.4/include \
../scripts
 
LOCAL_CFLAGS := \
-DFT2_BUILD_LIBRARY -DDARWIN_NO_CARBON -DHAVE_STDINT_H
 
LOCAL_MODULE := mupdfthirdparty
LOCAL_SRC_FILES := \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_arith.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_arith_int.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_arith_iaid.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_huffman.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_segment.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_page.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_symbol_dict.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_text.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_generic.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_refinement.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_mmr.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_image.c \
$(MY_ROOT)/thirdparty/jbig2dec/jbig2_metadata.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/bio.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/cio.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/dwt.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/event.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/image.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/j2k.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/j2k_lib.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/jp2.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/jpt.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/mct.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/mqc.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/openjpeg.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/pi.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/raw.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/t1.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/t2.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/tcd.c \
$(MY_ROOT)/thirdparty/openjpeg-1.4/libopenjpeg/tgt.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jaricom.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jcapimin.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jcapistd.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jcarith.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jccoefct.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jccolor.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jcdctmgr.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jchuff.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jcinit.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jcmainct.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jcmarker.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jcmaster.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jcomapi.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jcparam.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jcprepct.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jcsample.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jctrans.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdapimin.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdapistd.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdarith.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdatadst.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdatasrc.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdcoefct.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdcolor.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jddctmgr.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdhuff.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdinput.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdmainct.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdmarker.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdmaster.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdmerge.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdpostct.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdsample.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jdtrans.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jerror.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jfdctflt.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jfdctfst.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jfdctint.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jidctflt.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jidctfst.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jidctint.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jquant1.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jquant2.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jutils.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jmemmgr.c \
$(MY_ROOT)/thirdparty/jpeg-8c/jmemansi.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/adler32.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/compress.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/crc32.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/deflate.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/gzclose.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/gzlib.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/gzread.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/gzwrite.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/infback.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/inffast.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/inflate.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/inftrees.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/trees.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/uncompr.c \
$(MY_ROOT)/thirdparty/zlib-1.2.5/zutil.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/autofit/autofit.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftbase.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftbbox.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftbdf.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftbitmap.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftdebug.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftgasp.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftglyph.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftgxval.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftinit.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftlcdfil.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftmm.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftotval.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftpfr.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftstroke.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftsynth.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftsystem.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/fttype1.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftwinfnt.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftxf86.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/base/ftpatent.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/bdf/bdf.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/cache/ftcache.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/cff/cff.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/cid/type1cid.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/gzip/ftgzip.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/lzw/ftlzw.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/pcf/pcf.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/pfr/pfr.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/psaux/psaux.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/pshinter/pshinter.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/psnames/psnames.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/raster/raster.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/smooth/smooth.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/sfnt/sfnt.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/truetype/truetype.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/type1/type1.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/type42/type42.c \
$(MY_ROOT)/thirdparty/freetype-2.4.4/src/winfonts/winfnt.c
 
include $(BUILD_STATIC_LIBRARY)
/contrib/media/updf/android/jni/mupdf.c
0,0 → 1,212
#include <jni.h>
#include <time.h>
#include <android/log.h>
#include <android/bitmap.h>
 
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
#include "fitz.h"
#include "mupdf.h"
 
#define LOG_TAG "libmupdf"
#define LOGI(...) __android_log_print(ANDROID_LOG_INFO,LOG_TAG,__VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
 
/* Set to 1 to enable debug log traces. */
#define DEBUG 0
 
/* Globals */
fz_colorspace *colorspace;
fz_glyph_cache *glyphcache;
pdf_xref *xref;
int pagenum = 1;
int resolution = 160;
float pageWidth = 100;
float pageHeight = 100;
fz_display_list *currentPageList;
fz_rect currentMediabox;
int currentRotate;
 
JNIEXPORT int JNICALL
Java_com_artifex_mupdf_MuPDFCore_openFile(JNIEnv * env, jobject thiz, jstring jfilename)
{
const char *filename;
char *password = "";
int accelerate = 1;
fz_error error;
int pages;
 
filename = (*env)->GetStringUTFChars(env, jfilename, NULL);
if (filename == NULL)
{
LOGE("Failed to get filename");
return 0;
}
 
if (accelerate)
fz_accelerate();
glyphcache = fz_new_glyph_cache();
colorspace = fz_device_rgb;
 
LOGE("Opening document...");
error = pdf_open_xref(&xref, filename, password);
if (error)
{
LOGE("Cannot open document: '%s'\n", filename);
return 0;
}
 
LOGE("Loading page tree...");
error = pdf_load_page_tree(xref);
if (error)
{
LOGE("Cannot load page tree: '%s'\n", filename);
return 0;
}
pages = pdf_count_pages(xref);
LOGE("Done! %d pages", pages);
 
return pages;
}
 
JNIEXPORT void JNICALL
Java_com_artifex_mupdf_MuPDFCore_gotoPageInternal(JNIEnv *env, jobject thiz, int page)
{
float zoom;
fz_matrix ctm;
fz_bbox bbox;
fz_error error;
fz_device *dev;
pdf_page *currentPage;
 
/* In the event of an error, ensure we give a non-empty page */
pageWidth = 100;
pageHeight = 100;
 
LOGE("Goto page %d...", page);
if (currentPageList != NULL)
{
fz_free_display_list(currentPageList);
currentPageList = NULL;
}
pagenum = page;
error = pdf_load_page(&currentPage, xref, pagenum);
if (error)
return;
zoom = resolution / 72;
currentMediabox = currentPage->mediabox;
currentRotate = currentPage->rotate;
ctm = fz_translate(0, -currentMediabox.y1);
ctm = fz_concat(ctm, fz_scale(zoom, -zoom));
ctm = fz_concat(ctm, fz_rotate(currentRotate));
bbox = fz_round_rect(fz_transform_rect(ctm, currentMediabox));
pageWidth = bbox.x1-bbox.x0;
pageHeight = bbox.y1-bbox.y0;
/* Render to list */
currentPageList = fz_new_display_list();
dev = fz_new_list_device(currentPageList);
error = pdf_run_page(xref, currentPage, dev, fz_identity);
pdf_free_page(currentPage);
if (error)
LOGE("cannot make displaylist from page %d", pagenum);
fz_free_device(dev);
}
 
JNIEXPORT float JNICALL
Java_com_artifex_mupdf_MuPDFCore_getPageWidth(JNIEnv *env, jobject thiz)
{
LOGE("PageWidth=%g", pageWidth);
return pageWidth;
}
 
JNIEXPORT float JNICALL
Java_com_artifex_mupdf_MuPDFCore_getPageHeight(JNIEnv *env, jobject thiz)
{
LOGE("PageHeight=%g", pageHeight);
return pageHeight;
}
 
JNIEXPORT jboolean JNICALL
Java_com_artifex_mupdf_MuPDFCore_drawPage(JNIEnv *env, jobject thiz, jobject bitmap,
int pageW, int pageH, int patchX, int patchY, int patchW, int patchH)
{
AndroidBitmapInfo info;
void *pixels;
int ret;
fz_error error;
fz_device *dev;
float zoom;
fz_matrix ctm;
fz_bbox bbox;
fz_pixmap *pix;
float xscale, yscale;
fz_bbox rect;
 
LOGI("In native method\n");
if ((ret = AndroidBitmap_getInfo(env, bitmap, &info)) < 0) {
LOGE("AndroidBitmap_getInfo() failed ! error=%d", ret);
return 0;
}
 
LOGI("Checking format\n");
if (info.format != ANDROID_BITMAP_FORMAT_RGBA_8888) {
LOGE("Bitmap format is not RGBA_8888 !");
return 0;
}
 
LOGI("locking pixels\n");
if ((ret = AndroidBitmap_lockPixels(env, bitmap, &pixels)) < 0) {
LOGE("AndroidBitmap_lockPixels() failed ! error=%d", ret);
return 0;
}
 
/* Call mupdf to render display list to screen */
LOGE("Rendering page=%dx%d patch=[%d,%d,%d,%d]",
pageW, pageH, patchX, patchY, patchW, patchH);
 
rect.x0 = patchX;
rect.y0 = patchY;
rect.x1 = patchX + patchW;
rect.y1 = patchY + patchH;
pix = fz_new_pixmap_with_rect_and_data(colorspace, rect, pixels);
if (currentPageList == NULL)
{
fz_clear_pixmap_with_color(pix, 0xd0);
return 0;
}
fz_clear_pixmap_with_color(pix, 0xff);
 
zoom = resolution / 72;
ctm = fz_translate(-currentMediabox.x0, -currentMediabox.y1);
ctm = fz_concat(ctm, fz_scale(zoom, -zoom));
ctm = fz_concat(ctm, fz_rotate(currentRotate));
bbox = fz_round_rect(fz_transform_rect(ctm,currentMediabox));
/* Now, adjust ctm so that it would give the correct page width
* heights. */
xscale = (float)pageW/(float)(bbox.x1-bbox.x0);
yscale = (float)pageH/(float)(bbox.y1-bbox.y0);
ctm = fz_concat(ctm, fz_scale(xscale, yscale));
bbox = fz_round_rect(fz_transform_rect(ctm,currentMediabox));
dev = fz_new_draw_device(glyphcache, pix);
fz_execute_display_list(currentPageList, dev, ctm, bbox);
fz_free_device(dev);
fz_drop_pixmap(pix);
LOGE("Rendered");
 
AndroidBitmap_unlockPixels(env, bitmap);
 
return 1;
}
 
JNIEXPORT void JNICALL
Java_com_artifex_mupdf_MuPDFCore_destroying(JNIEnv * env, jobject thiz)
{
fz_free_display_list(currentPageList);
currentPageList = NULL;
pdf_free_xref(xref);
xref = NULL;
fz_free_glyph_cache(glyphcache);
glyphcache = NULL;
}