本文介绍了PDF格式的位图图像conversoin使用mupdf位于Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用在我的Andr​​oid应用程序mupdf库中查看PDF文件。谁能告诉我怎么去使用mupdf库PDF的每个页面的位图图像?在此先感谢....

I'm using mupdf library in my android application to view the pdf files. Can anyone tell me how to get the bitmap images of each page of a pdf using mupdf library? Thanks in advance....

推荐答案

该库似乎被更新,如果叫一个DrawPage()不会呈现图像,但工作正常,如果我们给的updatePage()

The library seems to be updated and doesn't render images if called drawPage() but works fine if we give updatePage()

找到示例源$ C ​​$ C以下段

Find snippet below from the sample source code

//Activity onCreate()

int x = Utils.getScreenSize(this)[0];
int y = Utils.getScreenSize(this)[1];

final ImageView imageView = (ImageView) findViewById(R.id.holderimageview); 
final Bitmap mSharedHqBm = Bitmap.createBitmap(x,y, Bitmap.Config.ARGB_8888);

new CancellableAsyncTask<Void, Void>(getDrawPageTask(mSharedHqBm, x,y, 0, 0, x, y)) {

        @Override
        public void onPreExecute() {
            imageView.setImageBitmap(null);
            imageView.invalidate();

            // Show some imageholder/spinner/progress etc.
        }

        @Override
        public void onPostExecute(Void result) {
            imageView.setImageBitmap(mSharedHqBm);
            imageView.invalidate();
        }
    }

// method in activity
protected CancellableTaskDefinition<Void, Void> getDrawPageTask(final Bitmap bm, final int sizeX, final int sizeY, final int patchX, final int patchY, final int patchWidth, final int patchHeight) { return new MuPDFCancellableTaskDefinition<Void, Void>(core) {
        @Override
        public Void doInBackground(MuPDFCore.Cookie cookie, Void ... params) {
            // Workaround bug in Android Honeycomb 3.x, where the bitmap generation count
            // is not incremented when drawing.
            if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB &&                       Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH)                 bm.eraseColor(0);
            core.updatePage(bm, somepagenumber, sizeX, sizeY, patchX, patchY, patchWidth, patchHeight, cookie);
            return null;
            }
        };
}

这篇关于PDF格式的位图图像conversoin使用mupdf位于Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-16 10:49