use of org.ebookdroid.common.bitmaps.BitmapRef in project LibreraReader by foobnix.
the class DjvuPage method renderThumbnail.
@Override
public Bitmap renderThumbnail(int width, int originW, int originH) {
if (originW < 0 || originH <= 0) {
originW = width;
originH = (int) (width * 1.3);
}
RectF rectF = new RectF(0, 0, 1f, 1f);
float k = (float) originH / originW;
LOG.d("TEST", "Render!" + " w" + originW + " H " + originH + " " + k + " " + width * k);
BitmapRef renderBitmap = renderBitmap(width, (int) (width * k), rectF);
return renderBitmap.getBitmap();
}
use of org.ebookdroid.common.bitmaps.BitmapRef in project LibreraReader by foobnix.
the class DjvuPage method renderBitmap.
@Override
public BitmapRef renderBitmap(final int width, final int height, final RectF pageSliceBounds) {
LOG.d("Render DJVU Page", width, height, pageSliceBounds);
final int renderMode = AppSettings.getInstance().djvuRenderingMode;
BitmapRef bmp = null;
if (width > 0 && height > 0) {
bmp = BitmapManager.getBitmap("Djvu page", width, height, Bitmap.Config.RGB_565);
final int[] buffer = new int[width * height];
renderPageWrapper(pageHandle, contextHandle, width, height, pageSliceBounds.left, pageSliceBounds.top, pageSliceBounds.width(), pageSliceBounds.height(), buffer, renderMode);
if (MagicHelper.isNeedBC) {
MagicHelper.applyQuickContrastAndBrightness(buffer, width, height);
}
// if (AppState.get().isCustomizeBgAndColors) {
MagicHelper.udpateColorsMagic(buffer);
// }
bmp.getBitmap().setPixels(buffer, 0, width, 0, 0, width, height);
return bmp;
}
if (bmp == null) {
bmp = BitmapManager.getBitmap("Djvu page", 100, 1000, Bitmap.Config.RGB_565);
}
return bmp;
}
use of org.ebookdroid.common.bitmaps.BitmapRef in project LibreraReader by foobnix.
the class MuPdfPage method render.
public BitmapRef render(final Rect viewbox, final float[] ctm) {
try {
TempHolder.lock.lock();
if (isRecycled()) {
throw new RuntimeException("The page has been recycled before: " + this);
}
final int[] mRect = new int[4];
mRect[0] = viewbox.left;
mRect[1] = viewbox.top;
mRect[2] = viewbox.right;
mRect[3] = viewbox.bottom;
final int width = viewbox.width();
final int height = viewbox.height();
final int[] bufferarray = new int[width * height];
if (AppState.get().isTextFormat()) {
int color = MagicHelper.getBgColor();
int r = Color.red(color);
int g = Color.green(color);
int b = Color.blue(color);
renderPage(docHandle, pageHandle, mRect, ctm, bufferarray, r, g, b);
if (AppState.get().isReplaceWhite && MagicHelper.isNeedMagicSimple()) {
MagicHelper.udpateColorsMagicSimple(bufferarray);
}
} else if (MagicHelper.isNeedMagic()) {
if (AppState.get().isCustomizeBgAndColors) {
renderPage(docHandle, pageHandle, mRect, ctm, bufferarray, -1, -1, -1);
MagicHelper.udpateColorsMagic(bufferarray);
} else {
int color = MagicHelper.getBgColor();
if (!AppState.get().isDayNotInvert) {
color = ~color;
}
int r = Color.red(color);
int g = Color.green(color);
int b = Color.blue(color);
renderPage(docHandle, pageHandle, mRect, ctm, bufferarray, r, g, b);
}
} else {
renderPage(docHandle, pageHandle, mRect, ctm, bufferarray, -1, -1, -1);
}
if (MagicHelper.isNeedBC) {
MagicHelper.applyQuickContrastAndBrightness(bufferarray, width, height);
}
final BitmapRef b = BitmapManager.getBitmap("PDF page", width, height, Config.RGB_565);
b.getBitmap().setPixels(bufferarray, 0, width, 0, 0, width, height);
return b;
} finally {
TempHolder.lock.unlock();
}
}
use of org.ebookdroid.common.bitmaps.BitmapRef in project LibreraReader by foobnix.
the class MuPdfPage method renderSimple.
public BitmapRef renderSimple(final Rect viewbox, final float[] ctm) {
try {
TempHolder.lock.lock();
if (isRecycled()) {
throw new RuntimeException("The page has been recycled before: " + this);
}
final int[] mRect = new int[4];
mRect[0] = viewbox.left;
mRect[1] = viewbox.top;
mRect[2] = viewbox.right;
mRect[3] = viewbox.bottom;
final int width = viewbox.width();
final int height = viewbox.height();
final int[] bufferarray = new int[width * height];
renderPage(docHandle, pageHandle, mRect, ctm, bufferarray, -1, -1, -1);
final BitmapRef b = BitmapManager.getBitmap("PDF page", width, height, Config.RGB_565);
b.getBitmap().setPixels(bufferarray, 0, width, 0, 0, width, height);
return b;
} finally {
TempHolder.lock.unlock();
}
}
Aggregations