绘制绘制对象/位图,只有一部分 [英] draw only a portion of a Drawable/Bitmap

查看:123
本文介绍了绘制绘制对象/位图,只有一部分的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在想,如果有可能之后被加载到内存中,而无需创建一个新的位图绘制位图的只是一部分。我看到绘制对象拥有的setBounds方法,但林不知道,如果只绘制设置的区域或只是重新调整整个图像。谢谢你。

I was wondering if it is possible to draw only a portion of a bitmap after it is loaded into memory without creating a new Bitmap. I see Drawable has a setBounds method but im not sure if it only draws the area set or just resizes the entire image. Thank you.

推荐答案

假设你有一个主要的帆布画,你可以使用Canvas类的drawBitmap方法之一绘制装载位图的一个子集。

Assuming you have a main canvas to draw to, you can use one of the drawBitmap methods of the Canvas class to draw a subset of the loaded bitmap.

<一个href="http://developer.android.com/reference/android/graphics/Canvas.html#drawBitmap%28android.graphics.Bitmap,%20android.graphics.Rect,%20android.graphics.Rect,%20android.graphics.Paint%29">public无效drawBitmap(位图位图,矩形SRC,矩形DST,油漆涂​​料)

这篇关于绘制绘制对象/位图,只有一部分的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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