com.bumptech.glide.util.Util#getBitmapByteSize ( )源码实例Demo

下面列出了com.bumptech.glide.util.Util#getBitmapByteSize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: giffun   文件: BitmapPreFillRunner.java
/**
 * Attempts to allocate {@link Bitmap}s and returns {@code true} if there are more
 * {@link Bitmap}s to allocate and {@code false} otherwise.
 */
private boolean allocate() {
    long start = clock.now();
    while (!toPrefill.isEmpty() && !isGcDetected(start)) {
        PreFillType toAllocate = toPrefill.remove();
        Bitmap bitmap = Bitmap.createBitmap(toAllocate.getWidth(), toAllocate.getHeight(),
                toAllocate.getConfig());

        // Don't over fill the memory cache to avoid evicting useful resources, but make sure it's not empty so
        // we use all available space.
        if (getFreeMemoryCacheBytes() >= Util.getBitmapByteSize(bitmap)) {
            memoryCache.put(new UniqueKey(), BitmapResource.obtain(bitmap, bitmapPool));
        } else {
            addToBitmapPool(toAllocate, bitmap);
        }

        if (Log.isLoggable(TAG, Log.DEBUG)) {
            Log.d(TAG, "allocated [" + toAllocate.getWidth() + "x" + toAllocate.getHeight() + "] "
                    + toAllocate.getConfig() + " size: " + Util.getBitmapByteSize(bitmap));
        }
    }

    return !isCancelled && !toPrefill.isEmpty();
}
 
源代码2 项目: giffun   文件: SizeStrategy.java
@Override
public Bitmap get(int width, int height, Bitmap.Config config) {
    final int size = Util.getBitmapByteSize(width, height, config);
    Key key = keyPool.get(size);

    Integer possibleSize = sortedSizes.ceilingKey(size);
    if (possibleSize != null && possibleSize != size && possibleSize <= size * MAX_SIZE_MULTIPLE) {
        keyPool.offer(key);
        key = keyPool.get(possibleSize);
    }

    // Do a get even if we know we don't have a bitmap so that the key moves to the front in the lru pool
    final Bitmap result = groupedMap.get(key);
    if (result != null) {
        result.reconfigure(width, height, config);
        decrementBitmapOfSize(possibleSize);
    }

    return result;
}
 
源代码3 项目: giffun   文件: SizeConfigStrategy.java
@Override
public void put(Bitmap bitmap) {
    int size = Util.getBitmapByteSize(bitmap);
    Key key = keyPool.get(size, bitmap.getConfig());

    groupedMap.put(key, bitmap);

    NavigableMap<Integer, Integer> sizes = getSizesForConfig(bitmap.getConfig());
    Integer current = sizes.get(key.size);
    sizes.put(key.size, current == null ? 1 : current + 1);
}
 
源代码4 项目: giffun   文件: SizeConfigStrategy.java
@Override
public Bitmap get(int width, int height, Bitmap.Config config) {
    int size = Util.getBitmapByteSize(width, height, config);
    Key targetKey = keyPool.get(size, config);
    Key bestKey = findBestKey(targetKey, size, config);

    Bitmap result = groupedMap.get(bestKey);
    if (result != null) {
        // Decrement must be called before reconfigure.
        decrementBitmapOfSize(Util.getBitmapByteSize(result), result.getConfig());
        result.reconfigure(width, height,
                result.getConfig() != null ? result.getConfig() : Bitmap.Config.ARGB_8888);
    }
    return result;
}
 
源代码5 项目: giffun   文件: SizeConfigStrategy.java
@Override
public Bitmap removeLast() {
    Bitmap removed = groupedMap.removeLast();
    if (removed != null) {
        int removedSize = Util.getBitmapByteSize(removed);
        decrementBitmapOfSize(removedSize, removed.getConfig());
    }
    return removed;
}
 
源代码6 项目: giffun   文件: SizeStrategy.java
@Override
public void put(Bitmap bitmap) {
    int size = Util.getBitmapByteSize(bitmap);
    final Key key = keyPool.get(size);

    groupedMap.put(key, bitmap);

    Integer current = sortedSizes.get(key.size);
    sortedSizes.put(key.size, current == null ? 1 : current + 1);
}
 
源代码7 项目: glide-support   文件: ApplicationIconDecoder.java
@Override public Resource<Drawable> decode(ApplicationInfo source, int width, int height) throws IOException {
	Drawable icon = context.getPackageManager().getApplicationIcon(source);
	return new DrawableResource<Drawable>(icon) {
		@Override public int getSize() { // best effort
			if (drawable instanceof BitmapDrawable) {
				return Util.getBitmapByteSize(((BitmapDrawable)drawable).getBitmap());
			} else {
				return 1;
			}
		}
		@Override public void recycle() { /* not from our pool */ }
	};
}
 
源代码8 项目: giffun   文件: GifDrawableResource.java
@Override
public int getSize() {
    return drawable.getData().length + Util.getBitmapByteSize(drawable.getFirstFrame());
}
 
源代码9 项目: giffun   文件: GlideBitmapDrawableResource.java
@Override
public int getSize() {
    return Util.getBitmapByteSize(drawable.getBitmap());
}
 
源代码10 项目: giffun   文件: BitmapDrawableResource.java
@Override
public int getSize() {
    return Util.getBitmapByteSize(drawable.getBitmap());
}
 
源代码11 项目: RetroMusicPlayer   文件: BitmapPaletteResource.java
@Override
public int getSize() {
    return Util.getBitmapByteSize(bitmapPaletteWrapper.getBitmap());
}
 
源代码12 项目: giffun   文件: BitmapPreFiller.java
private static int getSizeInBytes(PreFillType size) {
    return Util.getBitmapByteSize(size.getWidth(), size.getHeight(), size.getConfig());
}
 
源代码13 项目: Orin   文件: BitmapPaletteResource.java
@Override
public int getSize() {
    return Util.getBitmapByteSize(bitmapPaletteWrapper.getBitmap());
}
 
源代码14 项目: giffun   文件: SizeConfigStrategy.java
@Override
public String logBitmap(int width, int height, Bitmap.Config config) {
    int size = Util.getBitmapByteSize(width, height, config);
    return getBitmapString(size, config);
}
 
源代码15 项目: giffun   文件: SizeConfigStrategy.java
@Override
public int getSize(Bitmap bitmap) {
    return Util.getBitmapByteSize(bitmap);
}
 
源代码16 项目: giffun   文件: SizeStrategy.java
@Override
public String logBitmap(int width, int height, Bitmap.Config config) {
    int size = Util.getBitmapByteSize(width, height, config);
    return getBitmapString(size);
}
 
源代码17 项目: giffun   文件: SizeStrategy.java
@Override
public int getSize(Bitmap bitmap) {
    return Util.getBitmapByteSize(bitmap);
}
 
源代码18 项目: giffun   文件: SizeStrategy.java
private static String getBitmapString(Bitmap bitmap) {
    int size = Util.getBitmapByteSize(bitmap);
    return getBitmapString(size);
}
 
源代码19 项目: MusicPlayer   文件: BitmapPaletteResource.java
@Override
public int getSize() {
    return Util.getBitmapByteSize(bitmapPaletteWrapper.getBitmap());
}
 
源代码20 项目: Music-Player   文件: BitmapPaletteResource.java
@Override
public int getSize() {
    return Util.getBitmapByteSize(bitmapPaletteWrapper.getBitmap());
}