com.bumptech.glide.util.Util.getBitmapByteSize()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.9k)|赞(0)|评价(0)|浏览(185)

本文整理了Java中com.bumptech.glide.util.Util.getBitmapByteSize()方法的一些代码示例,展示了Util.getBitmapByteSize()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.getBitmapByteSize()方法的具体详情如下:
包路径:com.bumptech.glide.util.Util
类名称:Util
方法名:getBitmapByteSize

Util.getBitmapByteSize介绍

[英]Returns the in memory size of android.graphics.Bitmap with the given width, height, and android.graphics.Bitmap.Config.
[中]返回android的内存大小。图样具有给定宽度、高度和宽度的位图。图样位图。配置。

代码示例

代码示例来源:origin: bumptech/glide

@Override
public int getSize() {
 return Util.getBitmapByteSize(bitmap);
}

代码示例来源:origin: bumptech/glide

@Override
public int getSize() {
 return Util.getBitmapByteSize(bitmap);
}

代码示例来源:origin: bumptech/glide

/**
 * Returns the allocated byte size of the given bitmap.
 *
 * @see #getBitmapByteSize(android.graphics.Bitmap)
 * @deprecated Use {@link #getBitmapByteSize(android.graphics.Bitmap)} instead. Scheduled to be
 * removed in Glide 4.0.
 */
@Deprecated
public static int getSize(@NonNull Bitmap bitmap) {
 return getBitmapByteSize(bitmap);
}

代码示例来源:origin: bumptech/glide

private static String getBitmapString(Bitmap bitmap) {
 int size = Util.getBitmapByteSize(bitmap);
 return getBitmapString(size);
}

代码示例来源:origin: bumptech/glide

@Override
public String logBitmap(Bitmap bitmap) {
 int size = Util.getBitmapByteSize(bitmap);
 return getBitmapString(size, bitmap.getConfig());
}

代码示例来源:origin: bumptech/glide

@Override
public String logBitmap(int width, int height, Bitmap.Config config) {
 int size = Util.getBitmapByteSize(width, height, config);
 return getBitmapString(size, config);
}

代码示例来源:origin: bumptech/glide

@Override
public String logBitmap(int width, int height, Bitmap.Config config) {
 int size = Util.getBitmapByteSize(width, height, config);
 return getBitmapString(size);
}

代码示例来源:origin: bumptech/glide

@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);
}

代码示例来源:origin: bumptech/glide

@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);
}

代码示例来源:origin: bumptech/glide

@Override
@Nullable
public Bitmap removeLast() {
 Bitmap removed = groupedMap.removeLast();
 if (removed != null) {
  int removedSize = Util.getBitmapByteSize(removed);
  decrementBitmapOfSize(removedSize, removed);
 }
 return removed;
}

代码示例来源:origin: bumptech/glide

@Override
@Nullable
public Bitmap removeLast() {
 Bitmap removed = groupedMap.removeLast();
 if (removed != null) {
  final int removedSize = Util.getBitmapByteSize(removed);
  decrementBitmapOfSize(removedSize);
 }
 return removed;
}

代码示例来源:origin: bumptech/glide

private int getFrameSize() {
 return Util.getBitmapByteSize(getCurrentFrame().getWidth(), getCurrentFrame().getHeight(),
   getCurrentFrame().getConfig());
}

代码示例来源:origin: bumptech/glide

@Test
public void testReturnsCorrectBitmapSizeForDifferentDimensions() {
 int width = 100;
 int height = 100;
 Bitmap.Config config = Bitmap.Config.ARGB_8888;
 int initialSize = Util.getBitmapByteSize(width, height, config);
 int sizeOne = Util.getBitmapByteSize(width * 2, height, config);
 int sizeTwo = Util.getBitmapByteSize(width, height * 2, config);
 assertEquals(4 * width * height, initialSize);
 assertEquals(2 * initialSize, sizeOne);
 assertEquals(2 * initialSize, sizeTwo);
}

代码示例来源:origin: bumptech/glide

@Test
 public void getBitmapByteSize_withRGBA_F16_returnsCorrectSize() {
  int width = 100;
  int height = 200;
  assertThat(Util.getBitmapByteSize(width, height, Bitmap.Config.RGBA_F16))
    .isEqualTo(width * height * 8);
 }
}

代码示例来源:origin: bumptech/glide

@Test
public void testReturnsLargestSizeForNullConfig() {
 int width = 999;
 int height = 41324;
 int size = Util.getBitmapByteSize(width, height, null);
 assertEquals(width * height * 4, size);
}

代码示例来源:origin: bumptech/glide

@Test
public void testReturnsCorrectBitmapSizeForAlpha8Bitmap() {
 int width = 110;
 int height = 43;
 int size = Util.getBitmapByteSize(width, height, Bitmap.Config.ALPHA_8);
 assertEquals(width * height, size);
}

代码示例来源:origin: bumptech/glide

@Test
public void testReturnsCorrectBitmapSizeForRgb565() {
 int width = 34;
 int height = 1444;
 int size = Util.getBitmapByteSize(width, height, Bitmap.Config.RGB_565);
 assertEquals(width * height * 2, size);
}

代码示例来源:origin: bumptech/glide

@Test
public void testReturnsCorrectBitmapSizeForARGB4444() {
 int width = 4454;
 int height = 1235;
 int size = Util.getBitmapByteSize(width, height, Bitmap.Config.ARGB_4444);
 assertEquals(width * height * 2, size);
}

代码示例来源:origin: bumptech/glide

@Test
public void testReturnsCorrectBitmapSizeForARGB8888() {
 int width = 943;
 int height = 3584;
 int size = Util.getBitmapByteSize(width, height, Bitmap.Config.ARGB_8888);
 assertEquals(width * height * 4, size);
}

代码示例来源:origin: bumptech/glide

@Test
public void testReturnsSizeFromGifDecoderAndCurrentFrame() {
 int decoderByteSize = 123456;
 when(gifDecoder.getByteSize()).thenReturn(decoderByteSize);
 assertThat(loader.getSize()).isEqualTo(decoderByteSize + Util.getBitmapByteSize(firstFrame));
}

相关文章