Click here to Skip to main content
15,908,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir,

How do i convert any pixel format of bitmap to PixelFormat.Format1bppIndexedbitmap

Thanks and Regards
Posted

1 solution

Lets say you have an RGB image. This image has three channels Red, Green and Blue.
1) First, using RGB pixel value to compute a value (for example Gray value):
Gray=0.3*Red+0.59*Green+0.11*Blue;
2) Compare the calculated Gray value with a threshold value (for example threshold=128).
3) If (Gray > threshold) set that pixel's value as 1 (true), if (Gray <= threshold) set that pixel's as 0 (false).
4) Note that 8 pixels of the gray scale (or RGB) image must be set in a single pixel in the Format1bppIndexed image by doing the above process.

Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900