views:

83

answers:

1

Hi, 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 a a 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.

+3  A: 

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 (e.g. 3 for RGB, 4 for RGBA images).

frunsi
Thanks that explains exactly what i needed to know.I now have the gaussian blur working in color! Thanks again
Anthony McCormick
You should "accept" the answer
frunsi