我正在尝试使用androidstudio使用向量路径绘制位图,但是我对如何将图像绘制到屏幕上感到困惑。当我对宽度和高度使用较小的尺寸时,图像会放大,但对宽度和高度使用较大的尺寸时,图像会缩小。
public void draw() {
int temp1 = Utils.dpToPx((int) vectorModel.getWidth());
int temp2 = Utils.dpToPx((int) vectorModel.getHeight());
int temp3 = (int)vectorModel.getWidth();
int temp4 = (int)vectorModel.getHeight();
//temp1 = 2362,
//temp2 = 2254,
//temp3 = 900,
//temp4 = 859
castleBM = Bitmap.createBitmap(temp1, temp2, Bitmap.Config.ARGB_8888);
castleBM1 = Bitmap.createBitmap(temp3, temp4, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(castleBM);
Canvas canvas1 = new Canvas(castleBM2);
Paint paint = new Paint();
paint.setStyle(Paint.Style.FILL);
for(PathModel aPathModel : vectorModel.getPathModels()) {
if(!aPathModel.getName().equals("outline"))
{
paint.setColor(Color.RED);
canvas.drawPath(aPathModel.getPath(), paint);
paint.setColor(Color.BLUE);
canvas1.drawPath(aPathModel.getPath(), paint);
}
}
}
绘制位图的图像
暂无答案!
目前还没有任何答案,快来回答吧!