// Create test video frame
void CreateFrame(char * buffer, int w, int h, int bytespan)
{
int wxh = w * h;
static float seed = 1.0;
for (int i = 0; i < h; i ++)
{
char* line = buffer + i * bytespan;
for (int j = 0; j < w; j ++)
{
// RGB
line[0] = 255 * sin(((float)i / wxh * seed) * 3.14);
line[1] = 255 * cos(((float)j / wxh * seed) * 3.14);
line[2] = 255 * sin(((float)(i + j) / wxh * seed) * 3.14);
line += 3;
}
}
seed = seed + 2.2;
}
can any one please tall me what is line += 3; for?
and how to create such function analog in C#?
In C/C++, the value
linein line is actually a memory address of an array, andline[1]actually represents the value at the address of the variablelineplus a 1 item offset. (If the type of the items inlineis anint, then it means the address oflineplus four bytes; since it is achar, it means the address oflineplus one byte.)So,
line += 3means thatline[1]is now equivalent to[old "line" value][4]. The coder could have written the code as: