[英]Can you please help explain this code?
I have this function that I'm trying to convert but I just cant understand what is happening in some parts of the code.我有这个 function 我正在尝试转换,但我无法理解代码的某些部分发生了什么。 Could anyone please help me out and explain the code.
谁能帮我解释一下代码。 I just want to know what they do with the pointers.
我只想知道他们对指针做了什么。 There are some blank comments in the code where they do hell with the pointers, i just dont get it.
代码中有一些空白注释,他们用指针做地狱,我只是不明白。
Any help appreciated.任何帮助表示赞赏。
WORD** m_Pixels;
int pixel(int x, int y)
{
if (x<0 || y<0 || x>=m_Width || y>=m_Height)
return -1;
WORD *pPixels = m_Pixels[y];
//
int count = *pPixels++;
int index = 0;
register int i;
if (count > 0)
{
i = count;
do {
//
index += *pPixels++;
if (x < index)
{
return -1;
}
//
index += *pPixels;
//
pPixels += *pPixels;
pPixels++;
//
index += *pPixels;
//
pPixels += *pPixels;
pPixels++;
if (x < index)
{
return pPixels[x-index];
}
} while (--i);
}
return -1;
}
int count = *pPixels++;
Dereferences the pPixels
pointer to get the value and assigns it to count
and increment the pointer - this will make the pointer to point to the next element in the array ( m_Pixels
)取消引用
pPixels
指针以获取值并将其分配给count
和递增指针 - 这将使指针指向数组中的下一个元素 ( m_Pixels
)
index += *pPixels++;
Increment index
with the value, pointed by pPixels
and increment the pointer - this will make the pointer to point to the next element in the array用
pPixels
指向的值增加index
并增加指针 - 这将使指针指向数组中的下一个元素
pPixels += *pPixels;
pPixels += *pPixels;
Move the pointer X positions ahead, where X is the value, pointed by pPixels
将指针 X 位置向前移动,其中 X 是值,由
pPixels
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.