在android中将矩形绘制到位图的不同画布中

在android中将矩形绘制到位图的不同画布中,android,Android,我想使用位图在不同的画布上绘制一个矩形,但我的Paint类不起作用。 有人能告诉我我的密码出了什么问题吗 public Bitmap createBitmap(Rect rectImage, int i, int j) { Paint p = new Paint(); p.setStyle(Style.FILL_AND_STROKE); p.setAntiAlias(true); p.setFilterBitmap(true);

我想使用位图在不同的画布上绘制一个矩形,但我的Paint类不起作用。 有人能告诉我我的密码出了什么问题吗

public Bitmap createBitmap(Rect rectImage, int i, int j) {

        Paint p = new Paint();
        p.setStyle(Style.FILL_AND_STROKE);
        p.setAntiAlias(true);
        p.setFilterBitmap(true);
        p.setDither(true);
        p.setColor(Color.RED);

        Bitmap bitmap = Bitmap.createBitmap(rectImage.width() * 2,
                rectImage.height() * 2, Bitmap.Config.ARGB_8888);

        Canvas c = new Canvas(bitmap);

//      c.drawColor(Color.RED);

        c.drawRect(rectImage.left, rectImage.top, rectImage.right,
                rectImage.bottom, p);

        return bitmap;

    }
当我使用canvas.drawColor()时,它可以工作,但我的Paint类没有响应
提前谢谢

谢谢,但是我已经解决了这个问题,没有画地图lines@PrabinByanjankar若你们解决了ypur问题,那个么请更新你们的帖子,以便其他人可以从中引用。如果其他人也可以提供更精细的解决方案,如果可用的话。drawRect(新的Rect((bitmap.getWidth()-rectImage.width())/2,(bitmap.getHeight()-rectImage.height())/2,((bitmap.getWidth()-rectImage.width())/2)+rectImage.height(),((bitmap.getHeight()-rectImage.height())/2)+rectImage.height(),p);事情是我的矩形不在位图中,其余的都和上面一样
Bitmap tempBitmap = Bitmap.createScaledBitmap(bt, bt.getWidth(), bt.getHeight(), true);
Canvas canvas = new Canvas(tempBitmap);
Paint p = new Paint();
p.setStyle(Style.FILL_AND_STROKE);
p.setAntiAlias(true);
p.setFilterBitmap(true);
p.setDither(true);
p.setColor(Color.RED);

canvas.drawLine(x1, y1, x2, y1, p);//up
canvas.drawLine(x1, y1, x1, y2, p);//left
canvas.drawLine(x1, y2, x2, y2, p);//down
canvas.drawLine(x2, y1, x2, y2, p);

// rect ... 
//canvas.drawRect(/*all of my end coordinates*/, p);

ImageView iView = (ImageView)findViewById(R.id.imageViewPreview);
iView.setImageBitmap(tempBitmap);
iView.draw(canvas);