在drawArc android上绘制drawBitmap

时间:2016-09-23 06:21:55

标签: android canvas android-canvas

您好我想在drawArc上绘制Bitmap

到现在为止我做了以下事情

我使用下面的代码完成了循环进度,我已经完成了前四个45 *度

BitmapFactory.Options options = new BitmapFactory.Options();
        options.inPreferredConfig = Bitmap.Config.RGB_565;
        bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.ic_launcher, options);
        srcRect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
        dstRect = new Rect(0,0, bitmap.getWidth(), bitmap.getHeight());

onDrawMethod

  canvas.drawCircle(getWidth() / 2.0f, getHeight() / 2.0f, innerCircleRadius, innerCirclePaint);
  canvas.drawArc(finishedOuterRect, getStartingDegree(), getProgressAngle(), false, finishedPaint);
  canvas.drawArc(unfinishedOuterRect, getStartingDegree() + getProgressAngle(), 360 - getProgressAngle(), false, unfinishedPaint);
  double radius = getWidth()/2;

    double x = radius + (radius)*Math.cos(-45);
    double y = radius + (radius)*Math.sin(-45);

    double x1 = radius + (radius)*Math.cos(-135);
    double y1 = radius + (radius)*Math.sin(-135);

    double x2 = radius + (radius)*Math.cos(-225);
    double y2 = radius + (radius)*Math.sin(-225);

    double x3 = radius + (radius)*Math.cos(-315);
    double y3 = radius + (radius)*Math.sin(-315);

    canvas.drawCircle(getStartingDegree(), getProgressAngle(), 100, innerCirclePaint);

    canvas.drawBitmap(bitmap, (int)(x-bitmap.getWidth()/2), (int)(y-getWidth()/2), null);
    canvas.drawBitmap(bitmap, (int)(x1-bitmap.getWidth()/2), (int)(y1-getWidth()/2), null);
    canvas.drawBitmap(bitmap, (int)(x2-bitmap.getWidth()/2), (int)(y2-getWidth()/2), null);
    canvas.drawBitmap(bitmap, (int)(x3-bitmap.getWidth()/2), (int)(y3-getWidth()/2), null);

截图是

enter image description here

下面是我想要的图像......

enter image description here

上图的轮廓在下面

enter image description here

我想在drawArc上绘制位图,

因为我使用了Draw a Bitmap in Arc center?的引用,但它无法帮助我,我想在drawImage中设置坐标(X,Y),请任何可以帮助我的人

0 个答案:

没有答案
相关问题