@Override
    protected void onDraw(Canvas canvas) {
      canvas.drawARGB(80, 102, 204, 255);

      canvas.drawPicture(picture);

      canvas.translate(300, 0);
      canvas.drawPicture(picture, rect);

      canvas.translate(0, 300);
      canvas.drawPicture(picture, rect1);
    }
  private void setOverlayImage(int idx) {
    try {
      String groupPath = "images/overlays/svg/" + overlayGroup;

      if (overlays == null) overlays = getAssets().list(groupPath);

      bitmap =
          Bitmap.createBitmap(
              mOverlayView.getWidth(), mOverlayView.getHeight(), Bitmap.Config.ARGB_8888);
      canvas = new Canvas(bitmap);

      String imgPath = groupPath + '/' + overlays[idx];
      //    SVG svg = SVGParser.getSVGFromAsset(getAssets(), "images/overlays/svg/" +
      // overlays[idx],0xFFFFFF,0xCC0000);

      SVG svg = SVGParser.getSVGFromAsset(getAssets(), imgPath);

      Rect rBounds = new Rect(0, 0, mOverlayView.getWidth(), mOverlayView.getHeight());
      Picture p = svg.getPicture();
      canvas.drawPicture(p, rBounds);

      mOverlayView.setImageBitmap(bitmap);
    } catch (IOException ex) {
      Log.e(AppConstants.TAG, "error rendering overlay", ex);
      return;
    }
  }
예제 #3
0
    @Override
    protected void onDraw(Canvas canvas) {
      canvas.drawColor(Color.WHITE);

      canvas.drawPicture(mPicture);

      canvas.drawPicture(mPicture, new RectF(0, 100, getWidth(), 200));

      mDrawable.setBounds(0, 200, getWidth(), 300);
      mDrawable.draw(canvas);

      ByteArrayOutputStream os = new ByteArrayOutputStream();
      mPicture.writeToStream(os);
      InputStream is = new ByteArrayInputStream(os.toByteArray());
      canvas.translate(0, 300);
      canvas.drawPicture(Picture.createFromStream(is));
    }
  protected void drawCompass(final Canvas canvas, final float bearing) {
    final float centerX = mCompassCenterX * mScale;
    final float centerY = mCompassCenterY * mScale + (canvas.getHeight() - mMapView.getHeight());

    mCompassMatrix.setTranslate(-COMPASS_FRAME_CENTER_X, -COMPASS_FRAME_CENTER_Y);
    mCompassMatrix.postTranslate(centerX, centerY);

    canvas.save();
    canvas.setMatrix(mCompassMatrix);
    canvas.drawPicture(mCompassFrame);

    mCompassMatrix.setRotate(-bearing, COMPASS_ROSE_CENTER_X, COMPASS_ROSE_CENTER_Y);
    mCompassMatrix.postTranslate(-COMPASS_ROSE_CENTER_X, -COMPASS_ROSE_CENTER_Y);
    mCompassMatrix.postTranslate(centerX, centerY);

    canvas.setMatrix(mCompassMatrix);
    canvas.drawPicture(mCompassRose);
    canvas.restore();
  }
 private Bitmap pictureDrawableToBitmap(PictureDrawable pictureDrawable) {
   Bitmap bmp =
       Bitmap.createBitmap(
           pictureDrawable.getIntrinsicWidth(),
           pictureDrawable.getIntrinsicHeight(),
           Bitmap.Config.ARGB_8888);
   Canvas canvas = new Canvas(bmp);
   canvas.drawPicture(pictureDrawable.getPicture());
   return bmp;
 }
 @Override
 public void draw(Canvas canvas) {
   if (mPicture != null) {
     Rect bounds = getBounds();
     canvas.save();
     canvas.clipRect(bounds);
     canvas.translate(bounds.left, bounds.top);
     canvas.drawPicture(mPicture);
     canvas.restore();
   }
 }
예제 #7
0
  @Override
  public void draw(final Canvas c, final MapView mapView, final boolean shadow) {

    if (shadow) {
      return;
    }

    // If map views is animating, don't update, scale will be wrong.
    if (mapView.isAnimating()) {
      return;
    }

    final int zoomLevel = mapView.getZoomLevel();

    if (zoomLevel >= minZoom) {
      final Projection projection = mapView.getProjection();

      if (projection == null) {
        return;
      }

      final IGeoPoint center = projection.fromPixels((screenWidth / 2), screenHeight / 2);
      if (zoomLevel != lastZoomLevel
          || (int) (center.getLatitudeE6() / 1E6) != (int) (lastLatitude / 1E6)) {
        lastZoomLevel = zoomLevel;
        lastLatitude = center.getLatitudeE6();
        createScaleBarPicture(mapView);
      }

      mBounds.set(projection.getScreenRect());
      mBounds.offset((int) xOffset, (int) yOffset);

      mBounds.set(
          mBounds.left,
          mBounds.top,
          mBounds.left + scaleBarPicture.getWidth(),
          mBounds.top + scaleBarPicture.getHeight());
      c.drawPicture(scaleBarPicture, mBounds);
    }
  }
예제 #8
0
 @Override
 public void onDraw(Canvas canvas) {
   super.onDraw(canvas);
   canvas.drawPicture(picture);
 }