Search in sources :

Example 6 with CodecPageInfo

use of org.ebookdroid.core.codec.CodecPageInfo in project LibreraReader by foobnix.

the class MuPdfDocument method normalizeLinkTargetRect.

static void normalizeLinkTargetRect(final long docHandle, final int targetPage, final RectF targetRect, final int flags) {
    if ((flags & 0x0F) == 0) {
        targetRect.right = targetRect.left = 0;
        targetRect.bottom = targetRect.top = 0;
        return;
    }
    final CodecPageInfo cpi = new CodecPageInfo();
    try {
        TempHolder.lock.lock();
        MuPdfDocument.getPageInfo(docHandle, targetPage, cpi);
    } finally {
        TempHolder.lock.unlock();
    }
    final float left = targetRect.left;
    final float top = targetRect.top;
    if (((cpi.rotation / 90) % 2) != 0) {
        targetRect.right = targetRect.left = left / cpi.height;
        targetRect.bottom = targetRect.top = 1.0f - top / cpi.width;
    } else {
        targetRect.right = targetRect.left = left / cpi.width;
        targetRect.bottom = targetRect.top = 1.0f - top / cpi.height;
    }
}
Also used : CodecPageInfo(org.ebookdroid.core.codec.CodecPageInfo)

Example 7 with CodecPageInfo

use of org.ebookdroid.core.codec.CodecPageInfo in project LibreraReader by foobnix.

the class DocumentModel method initPages.

public void initPages(final IActivityController base, final IProgressIndicator task) {
    recyclePages();
    final BookSettings bs = SettingsManager.getBookSettings();
    if (base == null || bs == null || context == null || decodeService == null) {
        return;
    }
    final IView view = base.getView();
    final CodecPageInfo defCpi = new CodecPageInfo();
    defCpi.width = (view.getWidth());
    defCpi.height = (view.getHeight());
    int viewIndex = 0;
    try {
        final ArrayList<Page> list = new ArrayList<Page>();
        final CodecPageInfo[] infos = retrievePagesInfo(base, bs, task);
        for (int docIndex = 0; docIndex < infos.length; docIndex++) {
            if (TempHolder.get().loadingCancelled) {
                return;
            }
            if (!AppState.get().isCut) {
                CodecPageInfo cpi = infos[docIndex] != null ? infos[docIndex] : defCpi;
                final Page page = new Page(base, new PageIndex(docIndex, viewIndex++), PageType.FULL_PAGE, cpi);
                list.add(page);
            } else {
                final Page page1 = new Page(base, new PageIndex(docIndex, viewIndex++), PageType.LEFT_PAGE, infos[docIndex]);
                final Page page2 = new Page(base, new PageIndex(docIndex, viewIndex++), PageType.RIGHT_PAGE, infos[docIndex]);
                if (AppState.get().isCutRTL) {
                    list.add(page2);
                    list.add(page1);
                } else {
                    list.add(page1);
                    list.add(page2);
                }
            }
        }
        pages = list.toArray(new Page[list.size()]);
    } finally {
    }
}
Also used : IView(org.ebookdroid.ui.viewer.IView) CodecPageInfo(org.ebookdroid.core.codec.CodecPageInfo) ArrayList(java.util.ArrayList) BookSettings(org.ebookdroid.common.settings.books.BookSettings) Page(org.ebookdroid.core.Page) PageIndex(org.ebookdroid.core.PageIndex)

Aggregations

CodecPageInfo (org.ebookdroid.core.codec.CodecPageInfo)7 Bitmap (android.graphics.Bitmap)1 Matrix (android.graphics.Matrix)1 Rect (android.graphics.Rect)1 RectF (android.graphics.RectF)1 FileMeta (com.foobnix.dao2.FileMeta)1 DataInputStream (java.io.DataInputStream)1 EOFException (java.io.EOFException)1 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 BitmapRef (org.ebookdroid.common.bitmaps.BitmapRef)1 RawBitmap (org.ebookdroid.common.bitmaps.RawBitmap)1 PageCacheFile (org.ebookdroid.common.cache.PageCacheFile)1 BookSettings (org.ebookdroid.common.settings.books.BookSettings)1 Page (org.ebookdroid.core.Page)1 PageIndex (org.ebookdroid.core.PageIndex)1 CodecDocument (org.ebookdroid.core.codec.CodecDocument)1 CodecPage (org.ebookdroid.core.codec.CodecPage)1