本文整理汇总了Java中android.graphics.Bitmap.getRowBytes方法的典型用法代码示例。如果您正苦于以下问题:Java Bitmap.getRowBytes方法的具体用法?Java Bitmap.getRowBytes怎么用?Java Bitmap.getRowBytes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Bitmap
的用法示例。
在下文中一共展示了Bitmap.getRowBytes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getBitmapSize
import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
* Get the size in bytes of a bitmap in a BitmapDrawable. Note that from Android 4.4 (KitKat)
* onward this returns the allocated memory size of the bitmap which can be larger than the
* actual bitmap data byte count (in the case it was re-used).
*
* @param value
* @return size in bytes
*/
@TargetApi(VERSION_CODES.KITKAT)
public static int getBitmapSize(BitmapDrawable value) {
Bitmap bitmap = value.getBitmap();
// From KitKat onward use getAllocationByteCount() as allocated bytes can potentially be
// larger than bitmap byte count.
if (Utils.hasKitKat()) {
return bitmap.getAllocationByteCount();
}
if (Utils.hasHoneycombMR1()) {
return bitmap.getByteCount();
}
// Pre HC-MR1
return bitmap.getRowBytes() * bitmap.getHeight();
}
示例2: getBitmapByteSize
import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
* Returns the in memory size of the given {@link Bitmap} in bytes.
*/
@TargetApi(Build.VERSION_CODES.KITKAT)
public static int getBitmapByteSize(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 (NullPointerException e) {
// Do nothing.
}
}
return bitmap.getHeight() * bitmap.getRowBytes();
}
示例3: internalPrepareBitmap
import android.graphics.Bitmap; //导入方法依赖的package包/类
private void internalPrepareBitmap(CloseableReference<CloseableImage> newResult) {
if (newResult == null || !newResult.isValid()) {
return;
}
final CloseableImage closeableImage = newResult.get();
if (closeableImage == null || closeableImage.isClosed()) {
return;
}
if (closeableImage instanceof CloseableStaticBitmap) {
final CloseableStaticBitmap staticBitmap = (CloseableStaticBitmap) closeableImage;
final Bitmap bitmap = staticBitmap.getUnderlyingBitmap();
if (bitmap == null) {
return;
}
final int bitmapByteCount = bitmap.getRowBytes() * bitmap.getHeight();
if (bitmapByteCount < mMinBitmapSizeBytes) {
return;
}
if (bitmapByteCount > mMaxBitmapSizeBytes) {
return;
}
bitmap.prepareToDraw();
}
}
示例4: getBitmapSize
import android.graphics.Bitmap; //导入方法依赖的package包/类
public static int getBitmapSize(Bitmap bitmap){
if(bitmap != null){
try{
if(Build.VERSION.SDK_INT >= AndroidVersionCodes.KITKAT){
return bitmap.getAllocationByteCount();
}else if(Build.VERSION.SDK_INT >= AndroidVersionCodes.HONEYCOMB_MR1){
return bitmap.getByteCount();
}else{
return bitmap.getRowBytes() * bitmap.getHeight();
}
}catch (Exception e){
}
}
return 0;
}
示例5: getBitmapSize
import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
* 得到bitmap的大小
*/
public static int getBitmapSize(Bitmap bitmap) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { //API 19
return bitmap.getAllocationByteCount();
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR1) {//API 12
return bitmap.getByteCount();
}
// 在低版本中用一行的字节x高度
return bitmap.getRowBytes() * bitmap.getHeight(); //earlier version
}
示例6: lruCache
import android.graphics.Bitmap; //导入方法依赖的package包/类
public static LruCache lruCache() {
int maxMemory = (int) Runtime.getRuntime().maxMemory();
int cacheSize = maxMemory / 8;
LruCache<String, Bitmap> cache = new LruCache<String, Bitmap>(cacheSize) {
@Override
protected int sizeOf(String key, Bitmap value) {
return value.getRowBytes() * value.getHeight() / 1024;
}
};
// cache.put()
// cache.remove()
// cache.get()
return cache;
}
示例7: sizeOf
import android.graphics.Bitmap; //导入方法依赖的package包/类
private int sizeOf(String key, Bitmap value) {
return value.getRowBytes() * value.getHeight();
}
示例8: sizeOf
import android.graphics.Bitmap; //导入方法依赖的package包/类
@Override
protected int sizeOf(String key, Bitmap value) {
return value.getRowBytes() * value.getHeight();
}
示例9: getSize
import android.graphics.Bitmap; //导入方法依赖的package包/类
@Override
protected int getSize(Bitmap value) {
return value.getRowBytes() * value.getHeight();
}
示例10: getSizeInBytes
import android.graphics.Bitmap; //导入方法依赖的package包/类
private long getSizeInBytes(Bitmap bitmap) {
if(bitmap==null)
return 0;
return bitmap.getRowBytes() * bitmap.getHeight();
}
示例11: getSize
import android.graphics.Bitmap; //导入方法依赖的package包/类
protected int getSize(Bitmap value) {
return value.getRowBytes() * value.getHeight();
}
示例12: getSizeInBytes
import android.graphics.Bitmap; //导入方法依赖的package包/类
long getSizeInBytes(Bitmap bitmap) {
if(bitmap==null)
return 0;
return bitmap.getRowBytes() * bitmap.getHeight();
}
示例13: sizeOf
import android.graphics.Bitmap; //导入方法依赖的package包/类
@Override
protected int sizeOf(String key, Bitmap value) {
return value.getRowBytes() * value.getHeight() / 1024;
}
示例14: getBitmapSize
import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
* 获得bitmap的字节大小.
*/
public static int getBitmapSize(Bitmap bitmap)
{
return bitmap.getRowBytes() * bitmap.getHeight();
}
示例15: getAllocationByteCount
import android.graphics.Bitmap; //导入方法依赖的package包/类
public int getAllocationByteCount(Bitmap bitmap) {
return bitmap.getRowBytes() * bitmap.getHeight();
}