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


Java Bitmap.getRowBytes方法代码示例

本文整理汇总了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();
}
 
开发者ID:jjuiddong,项目名称:Android-Practice,代码行数:26,代码来源:ImageCache.java

示例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();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:Util.java

示例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();
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:29,代码来源:BitmapPrepareProducer.java

示例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;
}
 
开发者ID:miLLlulei,项目名称:Accessibility,代码行数:16,代码来源:BitmapUtils.java

示例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
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:14,代码来源:PictureUtil.java

示例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;
    }
 
开发者ID:wuhighway,项目名称:DailyStudy,代码行数:15,代码来源:BitmapUtil.java

示例7: sizeOf

import android.graphics.Bitmap; //导入方法依赖的package包/类
private int sizeOf(String key, Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:LruMemoryCache.java

示例8: sizeOf

import android.graphics.Bitmap; //导入方法依赖的package包/类
@Override
protected int sizeOf(String key, Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
开发者ID:mobillium,项目名称:omnicrow-android,代码行数:5,代码来源:BitmapLruCache.java

示例9: getSize

import android.graphics.Bitmap; //导入方法依赖的package包/类
@Override
protected int getSize(Bitmap value) {
	return value.getRowBytes() * value.getHeight();
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:5,代码来源:LRULimitedMemoryCache.java

示例10: getSizeInBytes

import android.graphics.Bitmap; //导入方法依赖的package包/类
private long getSizeInBytes(Bitmap bitmap) {
    if(bitmap==null)
        return 0;
    return bitmap.getRowBytes() * bitmap.getHeight();
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:6,代码来源:MemoryCache.java

示例11: getSize

import android.graphics.Bitmap; //导入方法依赖的package包/类
protected int getSize(Bitmap value) {
    return value.getRowBytes() * value.getHeight();
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:4,代码来源:LRULimitedMemoryCache.java

示例12: getSizeInBytes

import android.graphics.Bitmap; //导入方法依赖的package包/类
long getSizeInBytes(Bitmap bitmap) {
    if(bitmap==null)
        return 0;
    return bitmap.getRowBytes() * bitmap.getHeight();
}
 
开发者ID:tortuvshin,项目名称:health,代码行数:6,代码来源:MemoryCache.java

示例13: sizeOf

import android.graphics.Bitmap; //导入方法依赖的package包/类
@Override
protected int sizeOf(String key, Bitmap value) {
    return value.getRowBytes() * value.getHeight() / 1024;
}
 
开发者ID:sinhaDroid,项目名称:BlogBookApp,代码行数:5,代码来源:LruBitmapCache.java

示例14: getBitmapSize

import android.graphics.Bitmap; //导入方法依赖的package包/类
/**
 * 获得bitmap的字节大小.
 */
public static int getBitmapSize(Bitmap bitmap)
{
    return bitmap.getRowBytes() * bitmap.getHeight();
}
 
开发者ID:Evan-Galvin,项目名称:FreeStreams-TVLauncher,代码行数:8,代码来源:CacheUtils.java

示例15: getAllocationByteCount

import android.graphics.Bitmap; //导入方法依赖的package包/类
public int getAllocationByteCount(Bitmap bitmap) {
    return bitmap.getRowBytes() * bitmap.getHeight();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:4,代码来源:BitmapCompat.java


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