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


Java ReusableBitmapDrawable类代码示例

本文整理汇总了Java中org.osmdroid.tileprovider.ReusableBitmapDrawable的典型用法代码示例。如果您正苦于以下问题:Java ReusableBitmapDrawable类的具体用法?Java ReusableBitmapDrawable怎么用?Java ReusableBitmapDrawable使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ReusableBitmapDrawable类属于org.osmdroid.tileprovider包,在下文中一共展示了ReusableBitmapDrawable类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getDrawable

import org.osmdroid.tileprovider.ReusableBitmapDrawable; //导入依赖的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.ReusableBitmapDrawable; //导入依赖的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: handleTile

import org.osmdroid.tileprovider.ReusableBitmapDrawable; //导入依赖的package包/类
@Override
public void handleTile(MapTile pTile, int pX, int pY) {
	Drawable currentMapTile = mTileProvider.getMapTile(pTile);
	boolean isReusable = currentMapTile instanceof ReusableBitmapDrawable;
	final ReusableBitmapDrawable reusableBitmapDrawable =
			isReusable ? (ReusableBitmapDrawable) currentMapTile : null;
	if (currentMapTile == null) {
		currentMapTile = getLoadingTile();
	}

	if (currentMapTile != null) {
		mProjection.getPixelFromTile(pX, pY, mTileRect);
		if (isReusable) {
			reusableBitmapDrawable.beginUsingDrawable();
		}
		try {
			if (isReusable && !((ReusableBitmapDrawable) currentMapTile).isBitmapValid()) {
				currentMapTile = getLoadingTile();
				isReusable = false;
			}
			onTileReadyToDraw(mCanvas, currentMapTile, mTileRect);
		} finally {
			if (isReusable)
				reusableBitmapDrawable.finishUsingDrawable();
		}
	}

	if (Configuration.getInstance().isDebugTileProviders()) {
		mProjection.getPixelFromTile(pX, pY, mTileRect);
		mCanvas.drawText(pTile.toString(), mTileRect.left + 1,
				mTileRect.top + mDebugPaint.getTextSize(), mDebugPaint);
		mCanvas.drawLine(mTileRect.left, mTileRect.top, mTileRect.right, mTileRect.top,
				mDebugPaint);
		mCanvas.drawLine(mTileRect.left, mTileRect.top, mTileRect.left, mTileRect.bottom,
				mDebugPaint);
	}
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:38,代码来源:TilesOverlay.java

示例4: approximateTileFromLowerZoom

import org.osmdroid.tileprovider.ReusableBitmapDrawable; //导入依赖的package包/类
/**
 * Approximate a tile from a lower zoom level
 *
 * @since 5.6.5
 * @param pSrcDrawable Source tile bitmap
 * @param pMapTile Destination tile, for the same place on the planet as the source, but on a higher zoom
 * @param pZoomDiff Zoom level difference between the destination and the source; strictly positive
 * @return
 */
public static Bitmap approximateTileFromLowerZoom(
        final BitmapDrawable pSrcDrawable,
        final MapTile pMapTile, final int pZoomDiff) {
    if (pZoomDiff <= 0) {
        return null;
    }
    final int tileSizePixels = pSrcDrawable.getBitmap().getWidth();
    final Bitmap bitmap = getTileBitmap(tileSizePixels);
    final Canvas canvas = new Canvas(bitmap);
    final boolean isReusable = pSrcDrawable instanceof ReusableBitmapDrawable;
    final ReusableBitmapDrawable reusableBitmapDrawable = isReusable ?
            (ReusableBitmapDrawable) pSrcDrawable : null;
    boolean success = false;
    if (isReusable) {
        reusableBitmapDrawable.beginUsingDrawable();
    }
    try {
        if (!isReusable || reusableBitmapDrawable.isBitmapValid()) {
            final int srcSize = tileSizePixels >> pZoomDiff;
            if (srcSize == 0) {
                success = false;
            } else {
                final int srcX = (pMapTile.getX() % (1 << pZoomDiff)) * srcSize;
                final int srcY = (pMapTile.getY() % (1 << pZoomDiff)) * srcSize;
                final Rect srcRect = new Rect(srcX, srcY, srcX + srcSize, srcY + srcSize);
                final Rect dstRect = new Rect(0, 0, tileSizePixels, tileSizePixels);
                canvas.drawBitmap(pSrcDrawable.getBitmap(), srcRect, dstRect, null);
                success = true;
            }
        }
    } finally {
        if (isReusable)
            reusableBitmapDrawable.finishUsingDrawable();
    }
    if (!success) {
        return null;
    }
    return bitmap;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:49,代码来源:MapTileApproximater.java

示例5: tileLoaded

import org.osmdroid.tileprovider.ReusableBitmapDrawable; //导入依赖的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.ReusableBitmapDrawable类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。