drawBitmap()和的setPixels():什么是步幅?步幅、drawBitmap、setPixels

2023-09-06 02:13:03 作者:萌哒哒的小怪兽

能否取悦别人解释我(ASCII真的欢迎)的步幅参数代表着什么的Canvas.drawBitmap()而在Bitmap.setPixels()/getPixels()?我知道这是一种方式来跳过颜色数组中的元素,但如何?

Could please somebody explain me (ASCII is really welcome) what the stride argument stands for in Canvas.drawBitmap() and in Bitmap.setPixels()/getPixels()? I understand it's a way to skip elements in the colors array, but how?

推荐答案

在大多数情况下,步幅是相同的宽度。跨距是,如果你要复制/绘制位图的次区域是有用的。举例来说,如果你有一个100×100的位图,你想画的50×50右上角,你可以使用一个宽度50像素的和100px的一大步。

In most cases the stride is the same as the width. The stride is useful if you are trying to copy/draw a sub-region of a Bitmap. For instance, if you have a 100x100 bitmap and you want to draw the 50x50 top-right corner, you can use a width of 50px and a stride of 100px.