org.mapsforge.core.graphics.Bitmap.incrementRefCount()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(175)

本文整理了Java中org.mapsforge.core.graphics.Bitmap.incrementRefCount()方法的一些代码示例,展示了Bitmap.incrementRefCount()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bitmap.incrementRefCount()方法的具体详情如下:
包路径:org.mapsforge.core.graphics.Bitmap
类名称:Bitmap
方法名:incrementRefCount

Bitmap.incrementRefCount介绍

暂无

代码示例

代码示例来源:origin: mapsforge/mapsforge

public SymbolContainer(Point point, Display display, int priority, Bitmap symbol, float theta, boolean alignCenter) {
  super(point, display, priority);
  this.symbol = symbol;
  this.theta = theta;
  this.alignCenter = alignCenter;
  if (alignCenter) {
    double halfWidth = this.symbol.getWidth() / 2d;
    double halfHeight = this.symbol.getHeight() / 2d;
    this.boundary = new Rectangle(-halfWidth, -halfHeight, halfWidth, halfHeight);
  } else {
    this.boundary = new Rectangle(0, 0, this.symbol.getWidth(), this.symbol.getHeight());
  }
  this.symbol.incrementRefCount();
}

代码示例来源:origin: mapsforge/mapsforge

@Override
  public void run() {
    if (current != null) {
      // since we want to keep the green bitmap around, we have to increment
      // its ref count, otherwise it gets recycled automatically when it is
      // replaced with the other colour.
      current.incrementRefCount();
    }
    if (bitmapGreen.equals(current)) {
      marker.setBitmap(bitmapRed);
      current = bitmapRed;
    } else {
      marker.setBitmap(bitmapGreen);
      current = bitmapGreen;
    }
    redrawLayers();
    handler.postDelayed(this, 2000);
  }
}

代码示例来源:origin: mapsforge/mapsforge

@Override
  public void onDestroy() {
    handler.removeCallbacks(bitmapChanger);
    // we need to increment the ref count here as otherwise the bitmap gets
    // destroyed, but we might need to reuse it when this is only part of
    // a pause/resume cycle.
    current.incrementRefCount();
    super.onDestroy();
    bitmapRed.decrementRefCount();
    bitmapGreen.decrementRefCount();
  }
}

代码示例来源:origin: mapsforge/mapsforge

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
static Marker createTappableMarker(final Context c, int resourceIdentifier,
                  LatLong latLong) {
  Drawable drawable = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? c.getDrawable(resourceIdentifier) : c.getResources().getDrawable(resourceIdentifier);
  Bitmap bitmap = AndroidGraphicFactory.convertToBitmap(drawable);
  bitmap.incrementRefCount();
  return new Marker(latLong, bitmap, 0, -bitmap.getHeight() / 2) {
    @Override
    public boolean onTap(LatLong geoPoint, Point viewPosition,
               Point tapPoint) {
      if (contains(viewPosition, tapPoint)) {
        Toast.makeText(c,
            "The Marker was tapped " + geoPoint.toString(),
            Toast.LENGTH_SHORT).show();
        return true;
      }
      return false;
    }
  };
}

代码示例来源:origin: mapsforge/mapsforge

public static Bitmap getBitmapFromTitle(String title, Paint paint) {
  if (!captionViews.containsKey(title)) {
    TextView bubbleView = new TextView(context);
    Utils.setBackground(bubbleView, context.getResources().getDrawable(R.drawable.caption_background));
    bubbleView.setGravity(Gravity.CENTER);
    bubbleView.setMaxEms(20);
    bubbleView.setTextSize(10);
    bubbleView.setPadding(5, -2, 5, -2);
    bubbleView.setTextColor(android.graphics.Color.BLACK);
    bubbleView.setText(title);
    //Measure the view at the exact dimensions (otherwise the text won't center correctly)
    int widthSpec = View.MeasureSpec.makeMeasureSpec(paint.getTextWidth(title), View.MeasureSpec.EXACTLY);
    int heightSpec = View.MeasureSpec.makeMeasureSpec(paint.getTextHeight(title), View.MeasureSpec.EXACTLY);
    bubbleView.measure(widthSpec, heightSpec);
    //Layout the view at the width and height
    bubbleView.layout(0, 0, paint.getTextWidth(title), paint.getTextHeight(title));
    captionViews.put(title, Utils.viewToBitmap(context, bubbleView));
    captionViews.get(title).incrementRefCount(); // FIXME: is never reduced!
  }
  return captionViews.get(title);
}

代码示例来源:origin: mapsforge/mapsforge

@SuppressWarnings("deprecation")
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
protected void createLayers() {
  super.createLayers();
  // Bubble overlays
  for (DummyContent.DummyItem item : DummyContent.ITEMS) {
    TextView bubbleView = new TextView(this);
    Utils.setBackground(bubbleView, Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? getDrawable(R.drawable.balloon_overlay_unfocused) : getResources().getDrawable(R.drawable.balloon_overlay_unfocused));
    bubbleView.setGravity(Gravity.CENTER);
    bubbleView.setMaxEms(20);
    bubbleView.setTextSize(15);
    bubbleView.setTextColor(Color.BLACK);
    bubbleView.setText(item.text);
    bubble = Utils.viewToBitmap(this, bubbleView);
    bubble.incrementRefCount();
    this.mapView.getLayerManager().getLayers().add(new Marker(item.location, bubble, 0, -bubble.getHeight() / 2));
  }
}

代码示例来源:origin: sytolk/TaxiAndroidOpen

@UiThread
void showCarPosition(Cars cars) {
  if (TaxiApplication.isMapVisible() && cars != null) {
    //final List<Layer> overlayItems = carsOverlay.getOverlayItems();
    //overlayItems.clear();
    TextView bubbleView = new TextView(this);
    Utils.setBackground(bubbleView, getResources().getDrawable(R.drawable.balloon_overlay_unfocused));
    bubbleView.setGravity(Gravity.CENTER);
    bubbleView.setMaxEms(20);
    bubbleView.setTextSize(15);
    bubbleView.setTextColor(Color.BLACK);
    bubbleView.setText(cars.getNumber());
    bubble = Utils.viewToBitmap(this, bubbleView);
    bubble.incrementRefCount();
    if (cars.getCurrPosNorth() != null && cars.getCurrPosEast() != null) {
      Marker marker = new Marker(new LatLong(cars.getCurrPosNorth(), cars.getCurrPosEast()), bubble, 0, -bubble.getHeight() / 2);
      //marker.setDisplayModel(this.mapViews.get(0).getModel().displayModel);
      carsOverlay.add(marker);
      mapView.getLayerManager().getLayers().add(marker);
      //Log.i(TAG, "Car:" + cars.getNumber());
    }
    //carsOverlay.requestRedraw();
  }
}

代码示例来源:origin: org.mapsforge/mapsforge-core

public SymbolContainer(Point point, Display display, int priority, Bitmap symbol, float theta, boolean alignCenter) {
  super(point, display, priority);
  this.symbol = symbol;
  this.theta = theta;
  this.alignCenter = alignCenter;
  if (alignCenter) {
    double halfWidth = this.symbol.getWidth() / 2d;
    double halfHeight = this.symbol.getHeight() / 2d;
    this.boundary = new Rectangle(-halfWidth, -halfHeight, halfWidth, halfHeight);
  } else {
    this.boundary = new Rectangle(0, 0, this.symbol.getWidth(), this.symbol.getHeight());
  }
  this.symbol.incrementRefCount();
}

代码示例来源:origin: mapsforge/mapsforge

bitmapClimbingPeak.incrementRefCount();
balloon = getResources().getDrawable(R.drawable.marker_red);
Bitmap markerRedS = AndroidGraphicFactory.convertToBitmap(balloon);
markerRedS.incrementRefCount();
Paint paint1;
paint1 = AndroidGraphicFactory.INSTANCE.createPaint();
Bitmap bitmapBalloonSN = AndroidGraphicFactory
    .convertToBitmap(balloon);
bitmapBalloonSN.incrementRefCount();
balloon = getResources().getDrawable(R.drawable.balloon_s_s);
Bitmap bitmapBalloonSS = AndroidGraphicFactory.convertToBitmap(balloon);
bitmapBalloonSS.incrementRefCount();
Paint paint2;
paint2 = AndroidGraphicFactory.INSTANCE.createPaint();
bitmapBalloonMN.incrementRefCount();
balloon = getResources().getDrawable(R.drawable.balloon_m_s);
Bitmap bitmapBalloonMS = AndroidGraphicFactory
    .convertToBitmap(balloon);
bitmapBalloonMS.incrementRefCount();
Paint paint3;
paint3 = AndroidGraphicFactory.INSTANCE.createPaint();

代码示例来源:origin: sytolk/TaxiAndroidOpen

bubbleView.setText(newCRequest.getFullAddress());
bubble = Utils.viewToBitmap(this, bubbleView);
bubble.incrementRefCount();
Marker marker = new Marker(new LatLong(newCRequest.getNorth(), newCRequest.getEast()), bubble, 0, -bubble.getHeight() / 2);

相关文章