1

我正在尝试通过以下功能从画布中获取位图..但我得到的位图宽度和高度 -1 .....无法弄清楚为什么会发生...我附上了代码片段下面...请帮忙!!提前致谢 :)

`私有位图 createBitmapFromCanvas() {

    Bitmap bitmap = Bitmap.createBitmap(panelWidth, panelHeight,Bitmap.Config.ARGB_8888);       
    Canvas canvas = new Canvas();
    canvas.setBitmap(bitmap);
    canvas.drawRect(new Rect(0,0, panelWidth, panelHeight), new Paint());
    for (PathListForDraw points : finalPathList) {
            canvas.drawPath(points.getmPath(), points.getmPaint());
            // canvas.save();
    }

    return bitmap;

}`
4

0 回答 0