當前位置: 首頁>>代碼示例>>Java>>正文


Java BitmapPool類代碼示例

本文整理匯總了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;
	}
 
開發者ID:Arman92,項目名稱:Mapsforge-OsmDroid-GraphHopper,代碼行數:19,代碼來源:MFTileSource.java

示例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;
}
 
開發者ID:osmdroid,項目名稱:osmdroid,代碼行數:21,代碼來源:BitmapTileSourceBase.java

示例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);
}
 
開發者ID:osmdroid,項目名稱:osmdroid,代碼行數:14,代碼來源:MapTileApproximater.java

示例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);
}
 
開發者ID:osmdroid,項目名稱:osmdroid,代碼行數:12,代碼來源:MapTileDownloader.java


注:本文中的org.osmdroid.tileprovider.BitmapPool類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。