incrementing unsigned char *image

In this post, we will see how to resolve incrementing unsigned char *image

Question:

What does incrementing image+=3; actually do here. I’m trying to convert the same c++ code to C#, but unable to achieve this. I’m using byte[] image in C#, now how should I do image+=3 in C#. Is it scaling the image?

Best Answer:

From the code it is evident that the pointer points to an element of an array of unsigned char:
Next consider that image[i] is equivalent (really equivalent, that is how it is defined) to *(image + i), ie it increments the pointer by i and dereferences it. You can write image[0] to get the element image points to. You can type image[1] to get the next element in the array.
Lets call the actual array x then you can access its elements via incrementing image like this:
In other words, the author could have used some offset in the outer loop which increments by 3 in each iteration and then instead of image[ i ] they would have used image[ i + offset ]. Instead they choose to increment image which has the same effect.

If you have better answer, please add a comment about this, thank you!

Source: Stackoverflow.com