如何把画布上的ImageView的机器人画布、机器人、ImageView

2023-09-07 08:36:24 作者:扬花落满肩

我想在安卓上的ImageView显示画布内容

我不理解的 imageview.draw(画布);

这是我的code:

 公共类矩阵扩展活动{
    公共位图MYBITMAP,newbmp,位图,BMP;
    ImageView的ImageView的;

    涂料粉刷;
    @覆盖
    公共无效的onCreate(最终捆绑savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);
        ImageView的=(ImageView的)findViewById(R.id.ImageView01);
        imageview.setDrawingCacheEnabled(真正的);
    }

    保护无效的OnDraw(帆布油画)
    {
        imageview.draw(画布);
        MYBITMAP = BitmapFactory.de codeResource(getResources(),R.drawable.image);
        canvas.drawBitmap(MYBITMAP,0,0,油漆);
    }

}
 

解决方案

我想在安卓上的ImageView显示画布上的内容

所以,你想画什么就画布到您的ImageView?如果这是你想要的,那么你需要读取johike给出的链接,因为你似乎已经成为糊涂一点。

下面在code:

  imageview.draw(画布);
 

不等于画油画的内容到ImageView的。这意味着相反,绘制的ImageView到画布上。

为什么我要费尽心思造出一个不完美的绘画机器人

I want to display canvas contents on imageview in android

i am not understanding the imageview.draw(canvas);

Heres my code:

public class Matrix extends Activity {
    public Bitmap mybitmap,newbmp,bitmap,bmp;
    ImageView imageview;

    Paint paint;
    @Override
    public void onCreate(final Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        imageview=(ImageView)findViewById(R.id.ImageView01);
        imageview.setDrawingCacheEnabled(true);
    }

    protected void onDraw(Canvas canvas)
    {
        imageview.draw(canvas);
        mybitmap=BitmapFactory.decodeResource(getResources(), R.drawable.image);
        canvas.drawBitmap(mybitmap, 0, 0, paint);
    }

}

解决方案

"I want to display canvas contents on imageview in android"

So you want to draw what is on the Canvas in to your ImageView? If that's what you want then you need to read the links given by johike because you seem to have become confused a little.

The following in your code:

imageview.draw(canvas);

Does NOT mean draw the contents of canvas in to the imageview. It means the opposite, draw the imageview to the canvas.