i need to create a monochrome bitmap on my Android phone.
I have a 1024 byte array I/System.out:[0, 127, 62, 28, 28, 8, 0, 112, 14, 9... .
Each byte is 8 pixels( e.g. 62 -> 00111110, where 1 is a black pixel and 0 is a white pixel)
How can i do it?
Thank you!
First of all convert byte array into bitmap
Then You can convert the image to monochrome 32bpp using a ColorMatrix.
That simplifies the color->monochrome conversion. Now you can just do a getPixels() and read the lowest byte of each 32-bit pixel. If it's <128 it's a 0, otherwise it's a 1.
You can try this to convert each pixel into HSV space and use the value to determine if the Pixel on the target image should be black or white: