简体   繁体   English

简单的iphone图像处理源代码问题,这是做什么的

[英]Simple-iphone-image-processing source code question, what does this do

I am going through the source code for the above project and I don't understand the following lines of code can anyone help explain it to me please? 我正在浏览上述项目的源代码,我不明白以下几行代码可以帮助我解释一下吗? I am trying to get the code to work with color images as it currently only works with greyscale images. 我试图让代码与彩色图像一起使用,因为它目前只适用于灰度图像。 I have the main methods working however the filters only get applied to the top quarter of the returned images. 我有主要的方法,但过滤器只应用于返回图像的前四分之一。

//In the heeder file. //在heeder文件中

inline uint8_t* operator[](const int rowIndex) {
    return m_yptrs[rowIndex];
}

//in the .mm file //在.mm文件中

void Image::initYptrs() {
m_yptrs=(uint8_t **) malloc(sizeof(uint8_t *)*m_height);
for(int i=0; i<m_height; i++) {
    m_yptrs[i]=m_imageData+i*m_width;
    }
}

From my understanding it looks like it is creating aa reference to the pixels in the images however i don't understand this line of code. 根据我的理解,它看起来像是在创建对图像中像素的引用,但是我不理解这行代码。

m_yptrs[i]=m_imageData+i*m_width;

Thanks in advance. 提前致谢。

Image::initYptrs() initializes an array of pointers to the beginning of each row of the image. Image::initYptrs()初始化指向图像每行开头的指针数组。

The line in question should probably read 这条线应该可以阅读

m_yptrs[i] = m_imageData + i*BPP*m_width;

Where BPP is bytes per pixel (eg 3 for RGB, 4 for RGBA images). 其中BPP是每个像素的字节数(例如,RGB为3,RGBA图像为4)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM