本文整理汇总了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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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);
}