Skip to content

Instantly share code, notes, and snippets.

@fkruege
Last active March 13, 2016 02:04
Show Gist options
  • Select an option

  • Save fkruege/61bcf6de074e0d7b5541 to your computer and use it in GitHub Desktop.

Select an option

Save fkruege/61bcf6de074e0d7b5541 to your computer and use it in GitHub Desktop.
PDF Renderer
public Bitmap getBitmap(int position) {
int index = getIndexFromPosition(position);
if (mBitmapArray[index] == null) {
createBitmapAtIndex(index);
}
mBitmapArray[index].eraseColor(Color.TRANSPARENT);
return mBitmapArray[index];
}
public PDFPagerAdapter(Context context, String pdfPath, float renderQuality, int offScreenSize) {
this.pdfPath = pdfPath;
this.context = context;
mRenderQuality = renderQuality;
mOffScreenSize = offScreenSize;
init();
}
protected void initBitmapPool() {
PdfRenderer.Page samplePage = getPDFPage(0);
width = (int) (samplePage.getWidth() * mRenderQuality);
height = (int) (samplePage.getHeight() * mRenderQuality);
samplePage.close();
mBitmapPool = new SimpleBitmapPool(mOffScreenSize, width, height, Bitmap.Config.ARGB_8888);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment