本文整理匯總了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);
}