Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C# BitmapData class Scan0 and Stride properties meaning

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

like image 525
joonshen Avatar asked Apr 17 '11 06:04

joonshen


People also ask

What C is used for?

C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...

What is C in C language?

What is C? C is a general-purpose programming language created by Dennis Ritchie at the Bell Laboratories in 1972. It is a very popular language, despite being old. C is strongly associated with UNIX, as it was developed to write the UNIX operating system.

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

Is C language easy?

C is a general-purpose language that most programmers learn before moving on to more complex languages. From Unix and Windows to Tic Tac Toe and Photoshop, several of the most commonly used applications today have been built on C. It is easy to learn because: A simple syntax with only 32 keywords.


2 Answers

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

like image 99
Jon Skeet Avatar answered Sep 30 '22 01:09

Jon Skeet


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?

like image 30
Mark Redman Avatar answered Sep 30 '22 01:09

Mark Redman