Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BugFix - ThumbnailCacheManager Software rendering doesn't support hardware bitmaps #14270

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat;
import androidx.core.content.res.ResourcesCompat;
import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;

Expand Down Expand Up @@ -1260,9 +1261,11 @@ public AsyncMediaThumbnailDrawable(Resources res, Bitmap bitmap) {
}

/**
* adapted from https://stackoverflow.com/a/8113368
* adapted from <a href="https://stackoverflow.com/a/8113368">...</a>
*/
private static Bitmap handlePNG(Bitmap source, int newWidth, int newHeight) {
Bitmap softwareBitmap = source.copy(Bitmap.Config.ARGB_8888, false);

int sourceWidth = source.getWidth();
int sourceHeight = source.getHeight();

Expand All @@ -1281,8 +1284,9 @@ private static Bitmap handlePNG(Bitmap source, int newWidth, int newHeight) {
Bitmap dest = Bitmap.createBitmap(newWidth, newHeight, Bitmap.Config.ARGB_8888);

Canvas canvas = new Canvas(dest);
canvas.drawColor(MainApp.getAppContext().getResources().getColor(R.color.background_color_png));
canvas.drawBitmap(source, null, targetRect, null);
int color = ContextCompat.getColor(MainApp.getAppContext(),R.color.background_color_png);
canvas.drawColor(color);
canvas.drawBitmap(softwareBitmap, null, targetRect, null);

return dest;
}
Expand Down
Loading