How to get RGB value of a pixel in WinRT

后端 未结 2 1013
[愿得一人]
[愿得一人] 2021-01-16 12:45

I am trying to get the RGB value of each pixel in WinRT app. I can access an array of bytes containing PixelData but I don\'t know how to work with that so how

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-16 13:12

    Since you have a RGB image, tempBuffer[k + 0] is the red channel, tempBuffer[k + 1] is the green channel, and tempBuffer[k + 2] is the blue channel, i.e. tempBuffer is a 1D array. If you were looping over all the pixels, the pseudo code for this would be:

    for i = 0 to height - 1
        for j = 0 to width - 1
            k = (i * width + j) * 3
            r, g, b = tempBuffer[k + 0], tempBuffer[k + 1], tempBuffer[k + 2]
    

提交回复
热议问题