Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cb3bc0de authored by Daniel Lehmann's avatar Daniel Lehmann Committed by Android (Google) Code Review
Browse files

Merge "Prefer upsizing a down-sampled picture if size is close enough" into jb-mr1-dev

parents bf04c8a9 6b22e42b
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -52,10 +52,14 @@ public class BitmapUtil {
        if (targetExtent < 1) return 1;
        if (originalSmallerExtent < 1) return 1;

        // test what the best sample size is
        // Test what the best sample size is. To do that, we find the sample size that gives us
        // the best trade-off between resulting image size and memory requirement. We allow
        // the down-sampled image to be 20% smaller than the target size. That way we can get around
        // unfortunate cases where e.g. a 720 picture is requested for 362 and not down-sampled at
        // all. Why 20%? Why not. Prove me wrong.
        int extent = originalSmallerExtent;
        int sampleSize = 1;
        while ((extent >> 1) >= targetExtent) {
        while ((extent >> 1) >= targetExtent * 0.8f) {
            sampleSize <<= 1;
            extent >>= 1;
        }