I need to get a pure black and white UIImage from another UIImage (not grayscale). Anyone can help me?
Thanks for reading.
EDITED:
Here
The code worked right for me,just need some tweak ...here are few changes I made to work it properly by assigning value to dataBitmap[] array
's zeroth index...
for (int i = 0; i < image.size.width * image.size.height * 4; i += 4) {
//here an index for zeroth element is assigned
if ((dataBitmap[i + 0]+dataBitmap[i + 1] + dataBitmap[i + 2] + dataBitmap[i + 3]) < (255 * 4 / 2)) {
// multiply four,instead of three
dataBitmap[i + 0] = 0;
dataBitmap[i + 1] = 0;
dataBitmap[i + 2] = 0;
dataBitmap[i + 3] = 0;
} else {
dataBitmap[i + 0] = 255;
dataBitmap[i + 1] = 255;
dataBitmap[i + 2] = 255;
dataBitmap[i + 3] = 255;
}
}
Hope it will work.