本文整理了Java中android.graphics.Bitmap.getRowBytes()
方法的一些代码示例,展示了Bitmap.getRowBytes()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bitmap.getRowBytes()
方法的具体详情如下:
包路径:android.graphics.Bitmap
类名称:Bitmap
方法名:getRowBytes
暂无
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
/**
* Returns the size {@code Bitmap} in bytes.
* <p/>
* An entry's size must not change while it is in the cache.
*/
private int sizeOf(String key, Bitmap value) {
return value.getRowBytes() * value.getHeight();
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
protected int getSize(Bitmap value) {
return value.getRowBytes() * value.getHeight();
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
protected int getSize(Bitmap value) {
return value.getRowBytes() * value.getHeight();
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
protected int getSize(Bitmap value) {
return value.getRowBytes() * value.getHeight();
}
代码示例来源:origin: nostra13/Android-Universal-Image-Loader
@Override
protected int getSize(Bitmap value) {
return value.getRowBytes() * value.getHeight();
}
代码示例来源:origin: koral--/android-gif-drawable
/**
* Returns the minimum number of bytes that can be used to store pixels of the single frame.
* Returned value is the same for all the frames since it is based on the size of GIF screen.
* <p>This method should not be used to calculate the memory usage of the bitmap.
* Instead see {@link #getAllocationByteCount()}.
*
* @return the minimum number of bytes that can be used to store pixels of the single frame
*/
public int getFrameByteCount() {
return mBuffer.getRowBytes() * mBuffer.getHeight();
}
代码示例来源:origin: GitLqr/LQRWeChat
@Override
protected int sizeOf(String key, Bitmap value) {
// 这个方法会在每次存入缓存的时候调用
// return value.getByteCount();
return value.getRowBytes() * value.getHeight();
}
};
代码示例来源:origin: commonsguy/cw-omnibus
@Override
protected int sizeOf(String key, Bitmap value) {
return value.getRowBytes() * value.getHeight();
}
代码示例来源:origin: amitshekhariitbhu/Fast-Android-Networking
@Override
protected int sizeOf(String key, Bitmap value) {
return value.getRowBytes() * value.getHeight();
}
代码示例来源:origin: jiangqqlmj/FastDev4Android
@Override
protected int sizeOf(String key, Bitmap bitmap) {
return bitmap.getRowBytes() * bitmap.getHeight();
}
};
代码示例来源: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: Bilibili/DanmakuFlameMaster
@Override
public void build(int w, int h, int density, boolean checkSizeEquals, int bitsPerPixel) {
final DrawingCacheHolder holder = mHolder;
holder.buildCache(w, h, density, checkSizeEquals, bitsPerPixel);
mSize = mHolder.bitmap.getRowBytes() * mHolder.bitmap.getHeight();
}
代码示例来源:origin: stackoverflow.com
public static long getSizeInBytes(Bitmap bitmap) {
if(AndroidVersion.isHoneycombMr2OrHigher()) {
return bitmap.getByteCount();
} else {
return bitmap.getRowBytes() * bitmap.getHeight();
}
}
代码示例来源:origin: bumptech/glide
/**
* Returns the in memory size of the given {@link Bitmap} in bytes.
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
public static int getBitmapByteSize(@NonNull Bitmap bitmap) {
// The return value of getAllocationByteCount silently changes for recycled bitmaps from the
// internal buffer size to row bytes * height. To avoid random inconsistencies in caches, we
// instead assert here.
if (bitmap.isRecycled()) {
throw new IllegalStateException("Cannot obtain size for recycled Bitmap: " + bitmap
+ "[" + bitmap.getWidth() + "x" + bitmap.getHeight() + "] " + bitmap.getConfig());
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// Workaround for KitKat initial release NPE in Bitmap, fixed in MR1. See issue #148.
try {
return bitmap.getAllocationByteCount();
} catch (@SuppressWarnings("PMD.AvoidCatchingNPE") NullPointerException e) {
// Do nothing.
}
}
return bitmap.getHeight() * bitmap.getRowBytes();
}
代码示例来源: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: 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)
public void rowBytesIsAccurate() {
Bitmap b1 = Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
assertThat(b1.getRowBytes()).isEqualTo(40);
Bitmap b2 = Bitmap.createBitmap(10, 10, Bitmap.Config.RGB_565);
assertThat(b2.getRowBytes()).isEqualTo(20);
// Null Bitmap.Config is not allowed.
Bitmap b3 = Bitmap.createBitmap(10, 10, null);
b3.getRowBytes();
}
代码示例来源:origin: facebook/facebook-android-sdk
private static void compareImages(Bitmap bmp1, Bitmap bmp2) {
assertTrue(bmp1.getHeight() == bmp2.getHeight());
assertTrue(bmp1.getWidth() == bmp1.getWidth());
ByteBuffer buffer1 = ByteBuffer.allocate(bmp1.getHeight() * bmp1.getRowBytes());
bmp1.copyPixelsToBuffer(buffer1);
ByteBuffer buffer2 = ByteBuffer.allocate(bmp2.getHeight() * bmp2.getRowBytes());
bmp2.copyPixelsToBuffer(buffer2);
assertTrue(Arrays.equals(buffer1.array(), buffer2.array()));
}
代码示例来源:origin: robolectric/robolectric
@Test
public void decodeResource_shouldSetDefaultBitmapConfig() {
Bitmap bitmap = BitmapFactory.decodeResource(context.getResources(), R.drawable.an_image);
assertThat(bitmap.getConfig()).isEqualTo(Bitmap.Config.ARGB_8888);
assertThat(bitmap.getRowBytes()).isNotEqualTo(0);
}
代码示例来源:origin: bumptech/glide
@Test
public void testReturnsSizeFromGivenBitmap() {
assertEquals(harness.bitmap.getHeight() * harness.bitmap.getRowBytes(),
harness.create().getSize());
}
内容来源于网络,如有侵权,请联系作者删除!