在画布上绘制的图像 [英] Drawable image on a canvas

查看:109
本文介绍了在画布上绘制的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了教程,画布上的教程机器人现场抽奖的Andr​​oid系统。我想知道我怎样才能和图像到画布上,所以我可以在图像上画?就像从我绘制PNG文件的主面,所以我可以借鉴的图片。 这是Android 谢谢

I did the tutorial Drawing with Canvas in Android on tutorial for androids site . I was wondering how I can get and image to the canvas so I can draw on that image? like a png file from my drawable to the main surface so I can draw on that picture. This is for android Thank You

推荐答案

画在画布上绘制对象的好办法是不是自己进行解码,但它留给系统这样做的:

The good way to draw a Drawable on a canvas is not decoding it yourself but leaving it to the system to do so:

Drawable d = getResources().getDrawable(R.drawable.foobar);
d.setBounds(left, top, right, bottom);
d.draw(canvas);

这将与各种可绘制的,不仅是位图。而这也意味着,您可以再次如果只是大小的变化重新使用相同的绘制。

This will work with all kinds of drawables, not only bitmaps. And it also means that you can re-use that same drawable again if only the size changes.

这篇关于在画布上绘制的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆