In this article I will show you how to convert picture to black and white using c#. You need to pass the bitmap image to the following function. It has code,It will take the average of RGB values, in order to get the appropriate gray scale value and returns the result as bitmap object.
C# image manipulation:
public static Bitmap SetGrayscale(Bitmap btmap)
Bitmap temp = (Bitmap)btmap;
Bitmap bmap = (Bitmap)temp.Clone();
for (int i = 0; i < bmap.Width; i++)
for (int j = 0; j < bmap.Height; j++)
c = bmap.GetPixel(i, j);
byte gray = (byte)(.299 * c.R + .587 * c.G +.114 * c.B);
bmap.SetPixel(i, j, Color.FromArgb(gray, gray, gray));
return (Bitmap)bmap.Clone(); }
Create your own grayscale image convertor using this above C# code.
Post your comments / questions
- How to check PAN-Aadhaar is Linked or NOT?
- How to customize pagination for django admin?
- How to fix HAXM is not installed |in Android Studio
- How to fix CMOS Checksum Error in Computer or Laptop | SOLVED
- Reactivating windows after a Hardware change on PC or Laptop
- FIXED: Windows reported that the hardware of your device has changed. Error code :0xc004F211
- "redirect" is not defined pylance("reportUndefinedVariable)
- This action cannot be completed because the file is open in SQL Server(SQLEXPRESS) - FIXED