mirror of
https://github.com/nextcloud/android.git
synced 2024-11-28 10:18:59 +03:00
Merge pull request #14025 from nextcloud/bugfix/bitmap-add-color-filter
BugFix - Software rendering doesn't support hardware bitmaps
This commit is contained in:
commit
2b021c5a54
1 changed files with 3 additions and 7 deletions
|
@ -60,13 +60,9 @@ public final class BitmapUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap addColorFilter(Bitmap originalBitmap, int filterColor, int opacity) {
|
public static Bitmap addColorFilter(Bitmap originalBitmap, int filterColor, int opacity) {
|
||||||
int width = originalBitmap.getWidth();
|
Bitmap resultBitmap = originalBitmap.copy(Bitmap.Config.ARGB_8888, true);
|
||||||
int height = originalBitmap.getHeight();
|
|
||||||
|
|
||||||
Bitmap resultBitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888);
|
|
||||||
Canvas canvas = new Canvas(resultBitmap);
|
Canvas canvas = new Canvas(resultBitmap);
|
||||||
|
canvas.drawBitmap(resultBitmap, 0, 0, null);
|
||||||
canvas.drawBitmap(originalBitmap, 0, 0, null);
|
|
||||||
|
|
||||||
Paint paint = new Paint();
|
Paint paint = new Paint();
|
||||||
paint.setColor(filterColor);
|
paint.setColor(filterColor);
|
||||||
|
@ -74,7 +70,7 @@ public final class BitmapUtils {
|
||||||
paint.setAlpha(opacity);
|
paint.setAlpha(opacity);
|
||||||
|
|
||||||
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
|
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_ATOP));
|
||||||
canvas.drawRect(0, 0, width, height, paint);
|
canvas.drawRect(0, 0, resultBitmap.getWidth(), resultBitmap.getHeight(), paint);
|
||||||
|
|
||||||
return resultBitmap;
|
return resultBitmap;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue