本文整理汇总了Java中org.osmdroid.tileprovider.BitmapPool类的典型用法代码示例。如果您正苦于以下问题:Java BitmapPool类的具体用法?Java BitmapPool怎么用?Java BitmapPool使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BitmapPool类属于org.osmdroid.tileprovider包,在下文中一共展示了BitmapPool类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getDrawable
import org.osmdroid.tileprovider.BitmapPool; //导入依赖的package包/类
@Override
public Drawable getDrawable(final InputStream aFileInputStream) {
try {
// default implementation will load the file as a bitmap and create
// a BitmapDrawable from it
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
BitmapPool.getInstance().applyReusableOptions(bitmapOptions);
final Bitmap bitmap = BitmapFactory.decodeStream(aFileInputStream, null, bitmapOptions);
if (bitmap != null) {
return new ReusableBitmapDrawable(bitmap);
}
} catch (final OutOfMemoryError e) {
// logger.error("OutOfMemoryError loading bitmap");
System.gc();
// throw new LowMemoryException(e);
}
return null;
}
示例2: getDrawable
import org.osmdroid.tileprovider.BitmapPool; //导入依赖的package包/类
@Override
public Drawable getDrawable(final InputStream aFileInputStream) throws LowMemoryException {
try {
// default implementation will load the file as a bitmap and create
// a BitmapDrawable from it
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
BitmapPool.getInstance().applyReusableOptions(bitmapOptions);
final Bitmap bitmap = BitmapFactory.decodeStream(aFileInputStream, null, bitmapOptions);
if (bitmap != null) {
return new ReusableBitmapDrawable(bitmap);
}
} catch (final OutOfMemoryError e) {
Log.e(IMapView.LOGTAG,"OutOfMemoryError loading bitmap");
System.gc();
throw new LowMemoryException(e);
} catch (Exception ex) {
Log.w(IMapView.LOGTAG,"#547 Error loading bitmap" + pathBase(), ex);
}
return null;
}
示例3: getTileBitmap
import org.osmdroid.tileprovider.BitmapPool; //导入依赖的package包/类
/**
* Try to get a tile bitmap from the pool, otherwise allocate a new one
*
* @param pTileSizePx
* @return
*/
public static Bitmap getTileBitmap(final int pTileSizePx) {
final Bitmap bitmap = BitmapPool.getInstance().obtainSizedBitmapFromPool(pTileSizePx, pTileSizePx);
if (bitmap != null) {
return bitmap;
}
return Bitmap.createBitmap(pTileSizePx, pTileSizePx, Bitmap.Config.ARGB_8888);
}
示例4: tileLoaded
import org.osmdroid.tileprovider.BitmapPool; //导入依赖的package包/类
@Override
protected void tileLoaded(final MapTileRequestState pState, final Drawable pDrawable) {
removeTileFromQueues(pState.getMapTile());
// don't return the tile because we'll wait for the fs provider to ask for it
// this prevent flickering when a load of delayed downloads complete for tiles
// that we might not even be interested in any more
pState.getCallback().mapTileRequestCompleted(pState, null);
// We want to return the Bitmap to the BitmapPool if applicable
if (pDrawable instanceof ReusableBitmapDrawable)
BitmapPool.getInstance().returnDrawableToPool((ReusableBitmapDrawable) pDrawable);
}