简体   繁体   中英

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.

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

//in the .mm file

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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