Iphone convert color image to 2bit image (black-white)

后端 未结 3 991
半阙折子戏
半阙折子戏 2021-01-01 08:50

I need help to convert a color image to \"black and white\", not grayscale.

I what to do this with the iPhone SDK and Core Graphics, as I\'m convinced this is possib

3条回答
  •  梦毁少年i
    2021-01-01 08:53

    I thought I would just throw it out there that if you did not want to threshold the image, the code would look like ==>

    intensity = (pixelBuffer[index] + pixelBuffer[index + 1] + pixelBuffer[index + 2]) / 3.0;
    
    pixelBuffer[index] = (int)intensity;
    pixelBuffer[index + 1] = (int)intensity;  
    pixelBuffer[index + 2] = (int)intensity;
    

提交回复
热议问题