绘制绘制对象/位图,只有一部分位图、对象

2023-09-06 17:38:20 作者:痛失所爱

我在想,如果有可能之后被加载到内存中,而无需创建一个新的位图绘制位图的只是一部分。我看到绘制对象拥有的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.

public无效drawBitmap(位图位图,矩形SRC,矩形DST,油漆涂​​料)