C# BitmapData class Scan0 and Stride properties meaning

谁都会走 提交于 2019-12-30 10:00:11

问题


Can anyone explain what Scan0 and Stride properties of BitmapData class in C# are for?


回答1:


Are you talking about the BitmapData class? If so, the description in the documentation is reasonably clear, I think:

Scan0:

Gets or sets the address of the first pixel data in the bitmap. This can also be thought of as the first scan line in the bitmap.

In other words, this lets you find the data to examine or change - or even lets you make the bitmap to a completely different piece of data.

Stride:

The stride is the width of a single row of pixels (a scan line), rounded up to a four-byte boundary. If the stride is positive, the bitmap is top-down. If the stride is negative, the bitmap is bottom-up.

If you want to move from one row to the next, you need to add the stride to the address of the row you're currently looking at. Rows are aligned to 4 byte boundaries so that all kinds of code can access it more efficiently. (Various operations in CPUs are optimized to work on 4 byte or 8 byte boundaries.)




回答2:


The only place I have seen Scan and Stride is when dealing with images.

Related Question... any can explain the function of stride in bitmapdata?



来源:https://stackoverflow.com/questions/5691955/c-sharp-bitmapdata-class-scan0-and-stride-properties-meaning

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!