当前位置: 首页>>代码示例>>Java>>正文


Java Util.getBitmapByteSize方法代码示例

本文整理汇总了Java中com.bumptech.glide.util.Util.getBitmapByteSize方法的典型用法代码示例。如果您正苦于以下问题:Java Util.getBitmapByteSize方法的具体用法?Java Util.getBitmapByteSize怎么用?Java Util.getBitmapByteSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.bumptech.glide.util.Util的用法示例。


在下文中一共展示了Util.getBitmapByteSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testAllocationOrderDoesNotOverFillWithMultipleSizes

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Test
public void testAllocationOrderDoesNotOverFillWithMultipleSizes() {
  PreFillQueue allocationOrder = bitmapPreFiller.generateAllocationOrder(
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH, DEFAULT_BITMAP_HEIGHT)
          .setConfig(defaultBitmapConfig).build(),
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH / 2, DEFAULT_BITMAP_HEIGHT)
          .setConfig(defaultBitmapConfig).build(),
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH, DEFAULT_BITMAP_HEIGHT / 2)
          .setConfig(defaultBitmapConfig).build());

  long byteSize = 0;
  while (!allocationOrder.isEmpty()) {
    PreFillType current = allocationOrder.remove();
    byteSize +=
        Util.getBitmapByteSize(current.getWidth(), current.getHeight(), current.getConfig());
  }

  assertThat(byteSize).isIn(Range.atMost(poolSize + cacheSize));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:BitmapPreFillerTest.java

示例2: testAllocationOrderDoesNotOverFillWithMultipleSizesAndWeights

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Test
public void testAllocationOrderDoesNotOverFillWithMultipleSizesAndWeights() {
  PreFillQueue allocationOrder = bitmapPreFiller.generateAllocationOrder(new PreFillType[] {
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH, DEFAULT_BITMAP_HEIGHT)
          .setConfig(defaultBitmapConfig).setWeight(4).build(),
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH / 2, DEFAULT_BITMAP_HEIGHT)
          .setConfig(defaultBitmapConfig).build(),
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH, DEFAULT_BITMAP_HEIGHT / 3)
          .setConfig(defaultBitmapConfig).setWeight(3).build() });

  int byteSize = 0;
  while (!allocationOrder.isEmpty()) {
    PreFillType current = allocationOrder.remove();
    byteSize +=
        Util.getBitmapByteSize(current.getWidth(), current.getHeight(), current.getConfig());
  }

  assertThat(byteSize).isIn(Range.atMost(poolSize + cacheSize));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:BitmapPreFillerTest.java

示例3: get

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Override
@Nullable
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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:SizeStrategy.java

示例4: testAllocationOrderDoesNotOverFillWithMultipleSizes

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Test
public void testAllocationOrderDoesNotOverFillWithMultipleSizes() {
  PreFillQueue allocationOrder = bitmapPreFiller.generateAllocationOrder(new PreFillType[] {
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH, DEFAULT_BITMAP_HEIGHT)
          .setConfig(defaultBitmapConfig).build(),
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH / 2, DEFAULT_BITMAP_HEIGHT)
          .setConfig(defaultBitmapConfig).build(),
      new PreFillType.Builder(DEFAULT_BITMAP_WIDTH, DEFAULT_BITMAP_HEIGHT / 2)
          .setConfig(defaultBitmapConfig).build() });

  int byteSize = 0;
  while (!allocationOrder.isEmpty()) {
    PreFillType current = allocationOrder.remove();
    byteSize +=
        Util.getBitmapByteSize(current.getWidth(), current.getHeight(), current.getConfig());
  }

  assertThat(byteSize).isIn(Range.atMost(poolSize + cacheSize));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:20,代码来源:BitmapPreFillerTest.java

示例5: put

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:SizeStrategy.java

示例6: allocate

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
/**
 * Attempts to allocate {@link android.graphics.Bitmap}s and returns {@code true} if there are
 * more {@link android.graphics.Bitmap}s to allocate and {@code false} otherwise.
 */
private boolean allocate() {
  long start = clock.now();
  while (!toPrefill.isEmpty() && !isGcDetected(start)) {
    PreFillType toAllocate = toPrefill.remove();
    final Bitmap bitmap;
    if (!seenTypes.contains(toAllocate)) {
      seenTypes.add(toAllocate);
      bitmap = bitmapPool.getDirty(toAllocate.getWidth(), toAllocate.getHeight(),
          toAllocate.getConfig());
    } else {
      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 {
      bitmapPool.put(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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:BitmapPreFillRunner.java

示例7: put

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:SizeConfigStrategy.java

示例8: get

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Override
@Nullable
public Bitmap get(int width, int height, Bitmap.Config config) {
  int size = Util.getBitmapByteSize(width, height, config);
  Key bestKey = findBestKey(size, config);

  Bitmap result = groupedMap.get(bestKey);
  if (result != null) {
    // Decrement must be called before reconfigure.
    decrementBitmapOfSize(bestKey.size, result);
    result.reconfigure(width, height,
        result.getConfig() != null ? result.getConfig() : Bitmap.Config.ARGB_8888);
  }
  return result;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:16,代码来源:SizeConfigStrategy.java

示例9: removeLast

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Override
@Nullable
public Bitmap removeLast() {
  Bitmap removed = groupedMap.removeLast();
  if (removed != null) {
    final int removedSize = Util.getBitmapByteSize(removed);
    decrementBitmapOfSize(removedSize);
  }
  return removed;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:SizeStrategy.java

示例10: removeLast

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Override
@Nullable
public Bitmap removeLast() {
  Bitmap removed = groupedMap.removeLast();
  if (removed != null) {
    int removedSize = Util.getBitmapByteSize(removed);
    decrementBitmapOfSize(removedSize, removed);
  }
  return removed;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:SizeConfigStrategy.java

示例11: getFrameSize

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
private int getFrameSize() {
  return Util.getBitmapByteSize(getCurrentFrame().getWidth(), getCurrentFrame().getHeight(),
      getCurrentFrame().getConfig());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:GifFrameLoader.java

示例12: getSize

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Override
public int getSize() {
  return Util.getBitmapByteSize(drawable.getBitmap());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:BitmapDrawableResource.java

示例13: getSize

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Override
public int getSize() {
  return Util.getBitmapByteSize(bitmap);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:BitmapResource.java

示例14: logBitmap

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
@Override
public String logBitmap(int width, int height, Bitmap.Config config) {
  int size = Util.getBitmapByteSize(width, height, config);
  return getBitmapString(size);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:6,代码来源:SizeStrategy.java

示例15: getBitmapString

import com.bumptech.glide.util.Util; //导入方法依赖的package包/类
private static String getBitmapString(Bitmap bitmap) {
  int size = Util.getBitmapByteSize(bitmap);
  return getBitmapString(size);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:SizeStrategy.java


注:本文中的com.bumptech.glide.util.Util.getBitmapByteSize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。