本文整理了Java中android.graphics.Bitmap.getByteCount()
方法的一些代码示例,展示了Bitmap.getByteCount()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bitmap.getByteCount()
方法的具体详情如下:
包路径:android.graphics.Bitmap
类名称:Bitmap
方法名:getByteCount
暂无
代码示例来源:origin: Ramotion/expanding-collection-android
@Override
protected int sizeOf(Integer key, Bitmap bitmap) {
// The cache size will be measured in kilobytes rather than number of items.
return bitmap.getByteCount() / 1024;
}
};
代码示例来源:origin: Ramotion/cardslider-android
@Override
protected int sizeOf(Integer key, Bitmap bitmap) {
// The cache size will be measured in kilobytes rather than number of items.
return bitmap.getByteCount() / 1024;
}
};
代码示例来源:origin: stackoverflow.com
@TargetApi(Build.VERSION_CODES.HONEYCOMB_MR1)
protected int sizeOf(Bitmap data) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB_MR1) {
return data.getRowBytes() * data.getHeight();
} else {
return data.getByteCount();
}
}
代码示例来源:origin: stackoverflow.com
public static long getSizeInBytes(Bitmap bitmap) {
if(AndroidVersion.isHoneycombMr2OrHigher()) {
return bitmap.getByteCount();
} else {
return bitmap.getRowBytes() * bitmap.getHeight();
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@TargetApi(Build.VERSION_CODES.KITKAT)
private int byteCount(Bitmap b) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return(b.getAllocationByteCount());
}
return(b.getByteCount());
}
}
代码示例来源:origin: stackoverflow.com
/**
* Get the size in bytes of a bitmap in a BitmapDrawable.
* @param value
* @return size in bytes
*/
@TargetApi(12)
public static int getBitmapSize(BitmapDrawable value) {
Bitmap bitmap = value.getBitmap();
if (APIUtil.hasHoneycombMR1()) {
return bitmap.getByteCount();
}
// Pre HC-MR1
return bitmap.getRowBytes() * bitmap.getHeight();
}
代码示例来源:origin: square/assertj-android
@TargetApi(HONEYCOMB_MR1)
public BitmapAssert hasByteCount(int count) {
isNotNull();
int actualCount = actual.getByteCount();
assertThat(actualCount) //
.overridingErrorMessage("Expected byte count <%s> but was <%s>.", count, actualCount) //
.isEqualTo(count);
return this;
}
代码示例来源:origin: stackoverflow.com
/**
* returns the bytesize of the give bitmap
*/
public static int byteSizeOf(Bitmap bitmap) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
return bitmap.getAllocationByteCount();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {
return bitmap.getByteCount();
} else {
return bitmap.getRowBytes() * bitmap.getHeight();
}
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = NullPointerException.class)
@Config(minSdk = JELLY_BEAN_MR1)
public void byteCountIsAccurate() {
Bitmap b1 = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
assertThat(b1.getByteCount()).isEqualTo(400);
Bitmap b2 = Bitmap.createBitmap(10, 10, Bitmap.Config.RGB_565);
assertThat(b2.getByteCount()).isEqualTo(200);
// Null Bitmap.Config is not allowed.
Bitmap b3 = Bitmap.createBitmap(10, 10, null);
b3.getByteCount();
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = IllegalStateException.class)
public void throwsExceptionCopyPixelsFromBufferRecycled() {
Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
ByteBuffer buffer = ByteBuffer.allocate(bitmapOriginal.getByteCount());
bitmapOriginal.recycle();
bitmapOriginal.copyPixelsFromBuffer(buffer);
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = RuntimeException.class)
public void throwsExceptionCopyPixelsFromBufferNonArgb8888() {
Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_4444);
ByteBuffer buffer = ByteBuffer.allocate(bitmapOriginal.getByteCount());
bitmapOriginal.copyPixelsFromBuffer(buffer);
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = RuntimeException.class)
public void throwsExceptionCopyPixelsFromBufferTooSmall() {
Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
ByteBuffer buffer = ByteBuffer.allocate(bitmapOriginal.getByteCount() - 1);
bitmapOriginal.copyPixelsFromBuffer(buffer);
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = RuntimeException.class)
public void throwsExceptionCopyPixelsToBufferTooSmall() {
Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
ByteBuffer buffer = ByteBuffer.allocate(bitmapOriginal.getByteCount() - 1);
bitmapOriginal.copyPixelsToBuffer(buffer);
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = RuntimeException.class)
public void throwsExceptionCopyPixelsToBufferNonArgb8888() {
Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_4444);
ByteBuffer buffer = ByteBuffer.allocate(bitmapOriginal.getByteCount());
bitmapOriginal.copyPixelsToBuffer(buffer);
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = RuntimeException.class)
public void throwsExceptionCopyPixelsToLongBuffer() {
Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
LongBuffer buffer = LongBuffer.allocate(bitmapOriginal.getByteCount());
bitmapOriginal.copyPixelsToBuffer(buffer);
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = RuntimeException.class)
public void throwsExceptionCopyPixelsFromShortBuffer() {
Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
ShortBuffer buffer = ShortBuffer.allocate(bitmapOriginal.getByteCount());
bitmapOriginal.copyPixelsFromBuffer(buffer);
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = RuntimeException.class)
public void throwsExceptionCopyPixelsToShortBuffer() {
Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
ShortBuffer buffer = ShortBuffer.allocate(bitmapOriginal.getByteCount());
bitmapOriginal.copyPixelsToBuffer(buffer);
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = RuntimeException.class)
public void throwsExceptionCopyPixelsToIntBuffer() {
Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
IntBuffer buffer = IntBuffer.allocate(bitmapOriginal.getByteCount());
bitmapOriginal.copyPixelsToBuffer(buffer);
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = RuntimeException.class)
public void throwsExceptionCopyPixelsFromLongBuffer() {
Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
LongBuffer buffer = LongBuffer.allocate(bitmapOriginal.getByteCount());
bitmapOriginal.copyPixelsFromBuffer(buffer);
}
代码示例来源:origin: robolectric/robolectric
@Test(expected = RuntimeException.class)
public void throwsExceptionCopyPixelsFromIntBuffer() {
Bitmap bitmapOriginal = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
IntBuffer buffer = IntBuffer.allocate(bitmapOriginal.getByteCount());
bitmapOriginal.copyPixelsFromBuffer(buffer);
}
内容来源于网络,如有侵权,请联系作者删除!