hello and thank u for the lib.
i need to add night mode for pdf but i don't
what do shall ?
I made a grey scale option if this helps....
please give me the link ...
I dont have the code handy but basically i set a grey scale filter over the pdfview, i dont remember that i changed the whole activity, since some people may have issues reading in color hence the greyscale mode or night mode, etc.
This is what I did to do to accomplish a night mode. I basically just make the bitmap grayscale and then invert the colors. I put the line of code in the RenderingHandler class above the last line in the proceed method.
if (pdfView.isNightMode()) {
render = toNightMode(render, renderingTask.bestQuality);
}
The following method is also needed somewhere in the class:
private Bitmap toNightMode(Bitmap bmpOriginal, boolean bestQuality)
{
int width, height;
height = bmpOriginal.getHeight();
width = bmpOriginal.getWidth();
Bitmap nightModeBitmap = Bitmap.createBitmap(width, height, bestQuality ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565);
Canvas c = new Canvas(nightModeBitmap);
Paint paint = new Paint();
ColorMatrix grayScaleMatrix = new ColorMatrix();
grayScaleMatrix.setSaturation(0);
ColorMatrix invertMatrix =
new ColorMatrix(new float[] {
-1, 0, 0, 0, 255,
0, -1, 0, 0, 255,
0, 0, -1, 0, 255,
0, 0, 0, 1, 0});
ColorMatrix nightModeMatrix = new ColorMatrix();
nightModeMatrix.postConcat(grayScaleMatrix);
nightModeMatrix.postConcat(invertMatrix);
paint.setColorFilter(new ColorMatrixColorFilter(nightModeMatrix));
c.drawBitmap(bmpOriginal, 0, 0, paint);
return nightModeBitmap;
}
It should also be noted that this means each part will render a tad slower, but in my experience we're not even talking about a second so in my opinion it's not really visible to the naked eye.
Might be a good idea to also change the background color in PDFView:
if (nightMode) {
canvas.drawColor(Color.BLACK);
} else {
canvas.drawColor(Color.WHITE);
}
Hope that helps!
please give me the link ...
.onDraw(new OnDrawListener() {
@Override
public void onLayerDrawn(Canvas canvas, float pageWidth, float pageHeight, int displayedPage) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
canvas.drawColor(Color.argb(0.4f,0,0,0));}
}
})
Most helpful comment
This is what I did to do to accomplish a night mode. I basically just make the bitmap grayscale and then invert the colors. I put the line of code in the RenderingHandler class above the last line in the proceed method.
The following method is also needed somewhere in the class:
It should also be noted that this means each part will render a tad slower, but in my experience we're not even talking about a second so in my opinion it's not really visible to the naked eye.
Might be a good idea to also change the background color in PDFView:
Hope that helps!