C#BitmapData类Scan0和Stride属性的含义 [英] C# BitmapData class Scan0 and Stride properties meaning

查看:853
本文介绍了C#BitmapData类Scan0和Stride属性的含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能解释C#中BitmapData类的 Scan0 Stride 属性是做什么的?

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

推荐答案

您是否在谈论

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.

如果要从一行移到另一行,则需要将跨步添加到当前正在查看的行的地址.行与4个字节的边界对齐,以便所有类型的代码都可以更有效地访问它. (对CPU中的各种操作进行了优化,使其可以在4字节或8字节边界上工作.)

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.)

这篇关于C#BitmapData类Scan0和Stride属性的含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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