private Key findBestKey(Key key, int size, Bitmap.Config config) {
        Key result = key;
        for (Bitmap.Config possibleConfig : getInConfigs(config)) {
            NavigableMap<Integer, Integer> sizesForPossibleConfig = getSizesForConfig(possibleConfig);
            Integer possibleSize = sizesForPossibleConfig.ceilingKey(size);
            if (possibleSize != null && possibleSize <= size * MAX_SIZE_MULTIPLE) {
                if (possibleSize != size
                        || (possibleConfig == null ? config != null : !possibleConfig.equals(config))) {
                    keyPool.offer(key);
                    result = keyPool.get(possibleSize, possibleConfig);
                }
                break;
            }
        }
        return result;
    }
Keys {@link Bitmap Bitmaps} using both {@link Bitmap#getAllocationByteCount()} and
the {@link Bitmap.Config} returned from {@link Bitmap#getConfig()}.

<p>
    Using both the config and the byte size allows us to safely re-use a greater variety of
    {@link Bitmap Bitmaps}, which increases the hit rate of the pool and therefore the performance
    of applications. This class works around #301 by only allowing re-use of {@link Bitmap Bitmaps}
    with a matching number of bytes per pixel.
</p>
core/src/main/java/com/bumptech/glide/load/engine/bitmap_recycle/SizeConfigStrategy.java